(completion-setup-function): Set an initial value to `element-common-end' before...
authorMasatake YAMATO <jet@gyve.org>
Fri, 16 Apr 2004 08:45:40 +0000 (08:45 +0000)
committerMasatake YAMATO <jet@gyve.org>
Fri, 16 Apr 2004 08:45:40 +0000 (08:45 +0000)
lisp/ChangeLog
lisp/simple.el

index e8deedd..49a4c09 100644 (file)
@@ -1,3 +1,11 @@
+2004-04-16  Masatake YAMATO  <jet@gyve.org>
+
+       * simple.el (completion-setup-function): Set an initial value
+       to `element-common-end' before entering loop. Set a value
+       to `element-common-end' at the end of loop.
+       The bug is reported by Juri Linkov <juri@jurta.org> in emacs-devel
+       list.
+
 2004-04-16  Juanma Barranquero  <lektu@terra.es>
 
        * bookmark.el (bookmark-send-edited-annotation): Fix docstring.
index 6bc89ae..f894529 100644 (file)
@@ -987,7 +987,7 @@ as an argument limits undo to changes within the current region."
        (undo-start))
       ;; get rid of initial undo boundary
       (undo-more 1))
-    ;; If we got this far, the next command should be a consecutive undo. 
+    ;; If we got this far, the next command should be a consecutive undo.
     (setq this-command 'undo)
     ;; Check to see whether we're hitting a redo record, and if
     ;; so, ask the user whether she wants to skip the redo/undo pair.
@@ -4116,12 +4116,12 @@ The completion list buffer is available as the value of `standard-output'.")
 
 ;; This function goes in completion-setup-hook, so that it is called
 ;; after the text of the completion list buffer is written.
-(defface completion-emphasis 
+(defface completion-emphasis
   '((t (:inherit bold)))
   "Face put on the first uncommon character in completions in *Completions* buffer."
   :group 'completion)
 
-(defface completion-de-emphasis 
+(defface completion-de-emphasis
   '((t (:inherit default)))
   "Face put on the common prefix substring in completions in *Completions* buffer."
   :group 'completion)
@@ -4156,24 +4156,26 @@ The completion list buffer is available as the value of `standard-output'.")
              (setq completion-base-size 0))))
        ;; Put emphasis and de-emphasis faces on completions.
       (when completion-base-size
-       (let ((common-string-length (length 
-                                    (substring mbuf-contents 
-                                               completion-base-size)))
-             (element-start (next-single-property-change 
-                             (point-min)
-                             'mouse-face))
-             element-common-end)
-         (while element-start
-           (setq element-common-end  (+ element-start common-string-length))
+       (let* ((common-string-length (length
+                                     (substring mbuf-contents
+                                                completion-base-size)))
+              (element-start (next-single-property-change
+                              (point-min)
+                              'mouse-face))
+              (element-common-end (+ element-start common-string-length))
+              (maxp (point-max)))
+         (while (and element-start (< element-common-end maxp))
            (when (and (get-char-property element-start 'mouse-face)
                       (get-char-property element-common-end 'mouse-face))
              (put-text-property element-start element-common-end
                                 'font-lock-face 'completion-de-emphasis)
              (put-text-property element-common-end (1+ element-common-end)
                                 'font-lock-face 'completion-emphasis))
-           (setq element-start (next-single-property-change 
+           (setq element-start (next-single-property-change
                                 element-start
-                                'mouse-face)))))
+                                'mouse-face))
+           (if element-start
+               (setq element-common-end  (+ element-start common-string-length))))))
       ;; Insert help string.
       (goto-char (point-min))
       (if (display-mouse-p)