summaryrefslogtreecommitdiff
path: root/lisp/wid-edit.el
diff options
context:
space:
mode:
authorMauro Aranda <maurooaranda@gmail.com>2019-10-07 03:59:43 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2019-10-07 05:00:24 +0200
commit7d46b934ab60fdd58c46391636663ff85594c40b (patch)
treed9864f95abf67e7551aa85163aaab68fd5d1fc43 /lisp/wid-edit.el
parent821c96c1b0421e8cf6ae0133402918e4ebc1466f (diff)
downloademacs-7d46b934ab60fdd58c46391636663ff85594c40b.tar.gz
Only complete words inside of the string widget
* lisp/wid-edit.el ('string widget): Peek the word that ispell-complete-word will try to complete, and only offer completions when the word is inside of the field (bug#11046).
Diffstat (limited to 'lisp/wid-edit.el')
-rw-r--r--lisp/wid-edit.el11
1 files changed, 10 insertions, 1 deletions
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index a5999c0de8d..4d1a609809d 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -58,6 +58,10 @@
(require 'cl-lib)
(eval-when-compile (require 'subr-x)) ; when-let
+;; The `string' widget completion uses this.
+(declare-function ispell-get-word "ispell"
+ (following &optional extra-otherchars))
+
;;; Compatibility.
(defun widget-event-point (event)
@@ -3074,7 +3078,12 @@ as the value."
"A string."
:tag "String"
:format "%{%t%}: %v"
- :complete-function 'ispell-complete-word
+ :complete (lambda (widget)
+ (require 'ispell)
+ (let ((start (save-excursion (nth 1 (ispell-get-word nil)))))
+ (if (< start (widget-field-start widget))
+ (message "No word to complete inside field")
+ (ispell-complete-word))))
:prompt-history 'widget-string-prompt-value-history)
(define-widget 'regexp 'string