]> git.neil.brown.name Git - edlib.git/commitdiff
Make: change how default_arg in added.
authorNeilBrown <neil@brown.name>
Thu, 20 Apr 2023 22:12:27 +0000 (08:12 +1000)
committerNeilBrown <neil@brown.name>
Thu, 20 Apr 2023 22:12:27 +0000 (08:12 +1000)
We currently make the default arg 'replacable' so that typing any text
replaces it.  This is sometimes useful, but sometime awkward.
1/ It is clumsy to edit the arg - you need to abort the 'replaceable'
   state first
2/ it doesn't help with added option e.g. to grep.

So don't make it 'replaceable' but instead place the cursor before the
text.  Then it is easy to insert options or edit the text, and replacing
it is as simple as ctrl-K.

Signed-off-by: NeilBrown <neil@brown.name>
python/lib-make.py

index 3def10ff8a4a959311894799438271b17cf5b36d..66d7160aa73d71d14ec2f71f806d495068325df2 100644 (file)
@@ -895,9 +895,12 @@ def make_request(key, focus, num, num2, str1, mark, **a):
     if not p:
         return edlib.Efail
     if dflt_arg:
-        # The '1' says to make this mark selection replaceable
-        p.call("mode-set-mark", 1)
-        p.call("Replace", dflt_arg)
+        pnt = p.call("doc:point", ret='mark')
+        mk = pnt.dup()
+        p.call("Replace", dflt_arg, mk)
+        # Move point to start of insertion, for easy editing.
+        pnt.to_mark(mk)
+
     p.call("popup:set-callback", run_make)
     p["prompt"] = "%s Command" % cmd
     p["done-key"] = "N:%d:%s:%s" % (autosave, mode, dir)