summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2022-04-21 22:28:26 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2022-04-21 22:28:52 +0200
commitbdc5960b53d1d831e4b46b359894537b7c001593 (patch)
tree67e75fd72919016e7f8472aad6b96b0a66ba8dd2
parentb278015fd84a0e2d49a343cc33f7451001332d11 (diff)
corfu--in-region, corfu--auto-complete: Fix gud-gdb completion (Fix #157)
Copy the start marker returned by the `completion-at-point-function' only if is not already a marker. This ensures that markers created by the `completion-at-point-function' (and in particular its marker type) are kept intact. The `gud-gdb-completion-at-point' has a hack which uses an insert-before marker to hide some side effects of the completion process. It is unclear to me if always copying the markers is disallowed by the `completion-at-point' API. I believe the approach used by Corfu was not wrong. But this means then that `gud-gdb-completion-at-point' must be improved such that it doesn't rely on the insert-before hack anymore. The FIXME in `gud-gdb-completion-at-point` also hints at that.
-rw-r--r--corfu.el8
1 files changed, 5 insertions, 3 deletions
diff --git a/corfu.el b/corfu.el
index 2d4d6d8..84bfc2c 100644
--- a/corfu.el
+++ b/corfu.el
@@ -1083,8 +1083,8 @@ See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
(`(,newstr . ,newpt)
(pcase-let ((`(,base ,candidates ,total . ,_)
(corfu--recompute-candidates str pt table pred)))
- (setq beg (copy-marker beg)
- end (copy-marker end t)
+ (unless (markerp beg) (setq beg (copy-marker beg)))
+ (setq end (copy-marker end t)
completion-in-region--data (list beg end table pred))
(unless (equal str newstr)
(completion--replace beg end (concat newstr)))
@@ -1139,7 +1139,9 @@ See `completion-in-region' for the arguments BEG, END, TABLE, PRED."
(lambda () (eq beg (car-safe (funcall fun)))))
(completion-extra-properties plist))
(setq completion-in-region--data
- (list (copy-marker beg) (copy-marker end t) table
+ (list (if (markerp beg) beg (copy-marker beg))
+ (copy-marker end t)
+ table
(plist-get plist :predicate)))
(corfu--setup)
(corfu--update))))))