emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/completions-highlight-modifications 71f60b6 07/18: Fix corner ca


From: Jimmy Aguilar Mena
Subject: feature/completions-highlight-modifications 71f60b6 07/18: Fix corner case when going out of bounds
Date: Wed, 18 Nov 2020 22:30:35 -0500 (EST)

branch: feature/completions-highlight-modifications
commit 71f60b62a8abca84f1bb76c05603afced6a1c000
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>

    Fix corner case when going out of bounds
    
    * lisp/completions-highlight.el : Don't go anywhere when in the fist or
    last candidate.
    * Remove some redundant calls to with-current-buffer
---
 lisp/completions-highlight.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lisp/completions-highlight.el b/lisp/completions-highlight.el
index 00b7382..f0da382 100644
--- a/lisp/completions-highlight.el
+++ b/lisp/completions-highlight.el
@@ -63,9 +63,15 @@ N is set to 1 if not specified."
   "Move to and highlight the next item in the completion list.
 With prefix argument N, move N items (negative N means move backward).
 If completion highlight is enabled, highlights the selected candidate.
-Returns the completion string if available."
+Returns the completion string if available.
+If N is equal to zero returns the current candidate"
   (interactive "p")
-  (next-completion n)
+
+  (unless (zerop n)
+    (next-completion n)
+    (cond
+     ((eobp) (next-completion -1))
+     ((bobp) (next-completion 1))))
 
   (let* ((obeg (point))
          (oend (next-single-property-change obeg 'mouse-face nil (point-max)))
@@ -108,8 +114,7 @@ alive and active."
   `(and (window-live-p minibuffer-scroll-window)
        (eq t (frame-visible-p (window-frame minibuffer-scroll-window)))
        (with-selected-window minibuffer-scroll-window
-          (with-current-buffer (window-buffer minibuffer-scroll-window)
-            ,@body))))
+            ,@body)))
 
 (defun minibuffer-next-completion (n)
   "Execute `completions-highlight-next-completion' in *Completions*.
@@ -163,7 +168,6 @@ suffix."
          (completion-no-auto-exit t))
 
     (with-selected-window minibuffer-window
-      (with-current-buffer minibuffer-buffer
        (let* ((prompt-end (minibuffer-prompt-end))
               (cursor-pos (if obase-position
                               (cadr obase-position)
@@ -177,7 +181,7 @@ suffix."
           (choose-completion-string suffix minibuffer-buffer
                                     (list cursor-pos (point-max)))
           (add-face-text-property cursor-pos (+ cursor-pos suffix-len) 'shadow)
-          (goto-char cursor-pos))))))
+          (goto-char cursor-pos)))))
 
 
 (defvar completions-highlight-minibuffer-map



reply via email to

[Prev in Thread] Current Thread [Next in Thread]