]> git.eshelyaron.com Git - emacs.git/commitdiff
Only complete words inside of the string widget
authorMauro Aranda <maurooaranda@gmail.com>
Mon, 7 Oct 2019 01:59:43 +0000 (03:59 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 7 Oct 2019 03:00:24 +0000 (05:00 +0200)
* 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).

lisp/wid-edit.el

index a5999c0de8d249d5e9abb2ee70f03b6103c2a6ee..4d1a609809d2b26aeed0418478fe024478a09ff8 100644 (file)
 (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