emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/mct 3c429e74df: BREAKING: Remove line number functional


From: ELPA Syncer
Subject: [elpa] externals/mct 3c429e74df: BREAKING: Remove line number functionality
Date: Sat, 19 Mar 2022 00:57:43 -0400 (EDT)

branch: externals/mct
commit 3c429e74df61653131fb3e6b40952551c569db99
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    BREAKING: Remove line number functionality
    
    The original idea was to use line numbers the way we do in ordinary
    buffers.  That works in most cases, as completion candidates tend to be
    a few characters long.  However, there are instances where the candidate
    is a longer stretch of text that includes newline characters, page
    breaks, and the like: the assumption of one candidate per line number no
    longer holds true, leading to an awkward experience.
    
    Users are encouraged to give Avy a try.  We provide the mct-avy.el and
    document how to use it in the manual.  In short, it targets a candidate
    without moving the point to it.
---
 README.org | 82 +++-----------------------------------------------------------
 mct.el     | 79 -----------------------------------------------------------
 2 files changed, 3 insertions(+), 158 deletions(-)

diff --git a/README.org b/README.org
index f68d7262d1..8246bbfe7b 100644
--- a/README.org
+++ b/README.org
@@ -663,20 +663,8 @@ Completions' buffer 
([[#h:97eb5898-1e52-4338-bd55-8c52f9d8ccd3][Cyclic behaviour
    can also be assigned to the global keymap, though MCT leaves such a
    decision up to the user (same for ~mct-focus-mini-or-completions~).
 
-   #+findex: mct-choose-completion-number
-5. Select a candidate by its line number by typing =M-g M-g= in either the
-   minibuffer or the =*Completions*= buffer.  This calls the command
-   ~mct-choose-completion-number~ which internally enables line numbers
-   and always makes the completions' buffer visible.  Selection in this
-   way exits the minibuffer.
-
-   NOTE: This method only works when ~mct-completions-format~ is set to
-   its default value of =one-column=.  The other formats show completions
-   in a grid view, which makes navigation based on line numbers
-   imprecise.
-
    #+findex: mct-choose-completion-dwim
-6. In prompts that allow the selection of multiple candidates
+5. In prompts that allow the selection of multiple candidates
    (internally via the ~completing-read-multiple~ function) using =M-RET=
    (~mct-choose-completion-dwim~) in the =*Completions*= will append the
    candidate at point to the list of selections and keep the completions
@@ -690,7 +678,7 @@ Completions' buffer 
([[#h:97eb5898-1e52-4338-bd55-8c52f9d8ccd3][Cyclic behaviour
    [[#h:162f232d-1e9d-4756-90d3-d6bf5bb4d8ef][Indicator for 
completing-read-multiple]].
 
    #+findex: mct-complete-and-exit
-7. When point is at the minibuffer, select the current candidate in
+6. When point is at the minibuffer, select the current candidate in
    the completions buffer with =C-RET= (~mct-complete-and-exit~), which
    has the same effect as first completing with =TAB= and then
    immediately exit the minibuffer with the completed candidate as the
@@ -698,7 +686,7 @@ Completions' buffer 
([[#h:97eb5898-1e52-4338-bd55-8c52f9d8ccd3][Cyclic behaviour
 
    #+findex: mct-next-completion-group
    #+findex: mct-previous-completion-group
-8. Emacs 28 has the ability to group candidates inside the completions'
+7. Emacs 28 has the ability to group candidates inside the completions'
    buffer under headings.  For example, the Consult package makes good
    use of those ([[#h:03227254-d467-4147-b8cf-2fe05a2e279b][Extensions]]).  
MCT provides motions that jump between
    such headings, placing the point at the first candidate right below
@@ -848,7 +836,6 @@ And with more options:
 (setq mct-completion-window-size (cons #'mct--frame-height-fraction 1))
 (setq mct-remove-shadowed-file-names t) ; works when `file-name-shadow-mode' 
is enabled
 (setq mct-hide-completion-mode-line t)
-(setq mct-show-completion-line-numbers nil)
 (setq mct-apply-completion-stripes t)
 (setq mct-minimum-input 3)
 (setq mct-live-completion t)
@@ -1075,69 +1062,6 @@ If you want to edit any key bindings, do it in these 
keymaps, not in
 those they extend and override (the names of the original ones are the
 same as above, minus the =mct-= prefix).
 
-** The use of remap for key bindings
-:PROPERTIES:
-:CUSTOM_ID: h:de19a74f-e305-4311-a9fe-2905bc5e06a0
-:END:
-#+cindex: Remap key bindings
-
-MCT tries not to hardcode key bindings in order to respect user
-configurations.  To this end, Emacs provides the ~remap~ mechanism which
-effectively intercepts the key binding of the original command and
-applies it to the one specified.  Think of it like redirecting from the
-old to the new one.
-
-The code looks like this:
-
-#+begin_src emacs-lisp
-(defvar mct-minibuffer-local-completion-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-j") #'exit-minibuffer)
-    (define-key map [remap goto-line] #'mct-choose-completion-number)
-    (define-key map [remap next-line] #'mct-switch-to-completions-top)
-    (define-key map [remap next-line-or-history-element] 
#'mct-switch-to-completions-top)
-    (define-key map [remap previous-line] #'mct-switch-to-completions-bottom)
-    (define-key map [remap previous-line-or-history-element] 
#'mct-switch-to-completions-bottom)
-    (define-key map (kbd "M-e") #'mct-edit-completion)
-    (define-key map (kbd "C-<return>") #'mct-complete-and-exit)
-    (define-key map (kbd "C-l") #'mct-list-completions-toggle)
-    map)
-  "Derivative of `minibuffer-local-completion-map'.")
-#+end_src
-
-The ~remap~ might cause unwanted behaviour in cases where a user
-maintaints their own remappings which conflict with those of the
-package.  Consider, for example, this scenario:
-
-#+begin_src emacs-lisp
-(require 'mct)
-
-;; Here goes the MCT setup
-
-;; More code...
-
-;; The user remaps `goto-line' to `my-goto-line-replacement' in the
-;; `global-map'.
-(define-key global-map [remap goto-line] #'my-goto-line-replacement)
-#+end_src
-
-If a user loads MCT first and later in their configuration defines a
-remap for ~goto-line~, then that will take precedence over what MCT wants
-to do.  The solution is for the user to update their code to specify an
-explicit key binding:
-
-#+begin_src emacs-lisp
-(require 'mct)
-
-;; Here goes the MCT setup
-
-;; More code...
-
-;; The user specifies an explicit key binding for
-;; `my-goto-line-replacement' in the `global-map'.
-(define-key global-map (kbd "M-g M-g") #'my-goto-line-replacement)
-#+end_src
-
 * User-level tweaks or custom code
 :PROPERTIES:
 :CUSTOM_ID: h:2630a7a3-1b11-4e9d-8282-0ea3bf9e2a5b
diff --git a/mct.el b/mct.el
index 03969e69f1..a11933deb8 100644
--- a/mct.el
+++ b/mct.el
@@ -84,11 +84,6 @@ Only works when variable `file-name-shadow-mode' is non-nil."
   :type 'boolean
   :group 'mct)
 
-(defcustom mct-show-completion-line-numbers nil
-  "Display line numbers in the Completions' buffer."
-  :type 'boolean
-  :group 'mct)
-
 (defcustom mct-apply-completion-stripes nil
   "When non-nil, use alternating backgrounds in the Completions."
   :type 'boolean
@@ -311,14 +306,6 @@ affairs."
   "Face for current candidate in the completions' buffer."
   :group 'mct)
 
-(declare-function display-line-numbers-mode "display-line-numbers")
-
-(defun mct--setup-line-numbers ()
-  "Set up line numbers for the completions' buffer."
-  (when (and (derived-mode-p 'completion-list-mode)
-             mct-show-completion-line-numbers)
-    (display-line-numbers-mode 1)))
-
 (defun mct--first-line-completion-p ()
   "Return non-nil if first line has completion candidates."
   (eq (line-number-at-pos (point-min))
@@ -866,68 +853,6 @@ If ARG is supplied, move that many completion groups at a 
time."
   (let ((completion-no-auto-exit t))
     (choose-completion)))
 
-(defvar display-line-numbers-mode)
-
-(defun mct--line-completion (n)
-  "Select completion on Nth line."
-  (with-current-buffer (window-buffer (mct--get-completion-window))
-    (goto-char (point-min))
-    (next-completion n)
-    (mct-choose-completion-exit)))
-
-(defun mct--line-bounds (n)
-  "Test if Nth line is in the buffer."
-  (with-current-buffer (window-buffer (mct--get-completion-window))
-    (let ((bounds (count-lines (point-min) (point-max))))
-      (unless (<= n bounds)
-        (user-error "%d is not within the buffer bounds (%d)" n bounds)))))
-
-(defun mct-goto-line ()
-  "Go to line N in the Completions' buffer."
-  (interactive nil mct-minibuffer-mode)
-  (let ((n (read-number "Line number: ")))
-    (mct--line-bounds n)
-    (select-window (mct--get-completion-window))
-    (mct--line-completion n)))
-
-(defun mct--line-number-selection ()
-  "Show line numbers and select one of them."
-  (with-current-buffer (window-buffer (mct--get-completion-window))
-    (let ((mct-show-completion-line-numbers t))
-      (if (bound-and-true-p display-line-numbers-mode)
-          (mct-goto-line)
-        (unwind-protect
-            (progn
-              (mct--setup-line-numbers)
-              (mct-goto-line))
-          (display-line-numbers-mode -1))))))
-
-(defun mct-choose-completion-number ()
-  "Select completion candidate on a given line number.
-Upon selecting the candidate, exit the minibuffer (i.e. confirm
-the choice right away).
-
-If the Completions' buffer is not visible, it is displayed.  Line
-numbers are shown on the side for during the operation (unless
-`mct-show-completion-line-numbers' is non-nil, in which case they
-are always visible).
-
-This command can be invoked from either the minibuffer or the
-Completions' buffer."
-  (interactive nil mct-minibuffer-mode)
-  (if (not (mct--one-column-p))
-      (user-error "Cannot select by line in grid view")
-    (let ((mct-remove-shadowed-file-names t)
-          (mct-live-update-delay most-positive-fixnum)
-          (enable-recursive-minibuffers t))
-      (unless (mct--get-completion-window)
-        (mct--show-completions))
-      (if (or (and (derived-mode-p 'completion-list-mode)
-                   (active-minibuffer-window))
-              (and (minibufferp)
-                   (mct--get-completion-window)))
-          (mct--line-number-selection)))))
-
 (defvar crm-completion-table)
 (defvar crm-separator)
 
@@ -1134,7 +1059,6 @@ region.")
 (defvar mct-minibuffer-completion-list-map
   (let ((map (make-sparse-keymap)))
     (define-key map [remap keyboard-quit] #'mct-keyboard-quit-dwim)
-    (define-key map [remap goto-line] #'mct-choose-completion-number)
     (define-key map [remap next-line] #'mct-next-completion-or-mini)
     (define-key map (kbd "n") #'mct-next-completion-or-mini)
     (define-key map [remap previous-line] #'mct-previous-completion-or-mini)
@@ -1155,7 +1079,6 @@ region.")
 (defvar mct-minibuffer-local-completion-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "C-j") #'exit-minibuffer)
-    (define-key map [remap goto-line] #'mct-choose-completion-number)
     (define-key map [remap next-line] #'mct-switch-to-completions-top)
     (define-key map [remap next-line-or-history-element] 
#'mct-switch-to-completions-top)
     (define-key map [remap previous-line] #'mct-switch-to-completions-bottom)
@@ -1188,7 +1111,6 @@ region.")
     (mct--setup-appearance)
     (mct--setup-completion-list-keymap)
     (mct--setup-highlighting)
-    (mct--setup-line-numbers)
     (cursor-sensor-mode)))
 
 ;;;;; Dynamic completion
@@ -1359,7 +1281,6 @@ minibuffer)."
     (mct--setup-appearance)
     (mct--region-setup-completion-list-keymap)
     (mct--setup-highlighting)
-    (mct--setup-line-numbers)
     (cursor-sensor-mode)))
 
 (defun mct--region-completion-done (&rest app)



reply via email to

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