diff options
author | Juri Linkov <juri@linkov.net> | 2020-11-27 11:17:12 +0200 |
---|---|---|
committer | Juri Linkov <juri@linkov.net> | 2020-11-27 11:17:12 +0200 |
commit | 13e032bab34fb33efee23184c02baa62ebe4dbfc (patch) | |
tree | 20e5b7b75e65226d369c0b3201de30c2e20f0fe6 /lisp/minibuffer.el | |
parent | 597a49b2e2ef664cc99a7f1a1ecad7d22df096a1 (diff) | |
download | emacs-13e032bab34fb33efee23184c02baa62ebe4dbfc.tar.gz |
Add completion-tab-width to align prefix chars with names in read-char-by-name
* lisp/international/mule-cmds.el (mule--ucs-names-affixation):
Replace mule--ucs-names-annotation to display chars in prefixes
that implements two FIXME items.
(read-char-by-name): Let-bind completion-tab-width to 4.
Use affixation-function instead of annotation-function.
* lisp/minibuffer.el (completion-tab-width): New variable.
(completion--insert-strings): Align colwidth to tab positions
when completion-tab-width is non-nil.
* lisp/simple.el (completion-setup-function): Set tab-width to
completion-tab-width when completion-tab-width is non-nil.
https://lists.gnu.org/archive/html/emacs-devel/2020-11/msg01263.html
Diffstat (limited to 'lisp/minibuffer.el')
-rw-r--r-- | lisp/minibuffer.el | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index 87bf3d36fa4..d44d8968221 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1134,6 +1134,7 @@ completion candidates than this number." (defvar-local completion-all-sorted-completions nil) (defvar-local completion--all-sorted-completions-location nil) (defvar completion-cycling nil) ;Function that takes down the cycling map. +(defvar completion-tab-width nil) (defvar completion-fail-discreetly nil "If non-nil, stay quiet when there is no match.") @@ -1718,6 +1719,11 @@ It also eliminates runs of equal strings." (row 0) (first t) (laststring nil)) + (unless (or tab-stop-list (null completion-tab-width) + (zerop (mod colwidth completion-tab-width))) + ;; Align to tab positions for the case + ;; when the caller uses tabs inside prefix. + (setq colwidth (- colwidth (mod colwidth completion-tab-width)))) ;; The insertion should be "sensible" no matter what choices were made ;; for the parameters above. (dolist (str strings) @@ -1758,9 +1764,10 @@ It also eliminates runs of equal strings." ;; already past the goal column, there is still ;; a space displayed. (set-text-properties (1- (point)) (point) - ;; We can't just set tab-width, because - ;; completion-setup-function will kill - ;; all local variables :-( + ;; We can set tab-width using + ;; completion-tab-width, but + ;; the caller can prefer using + ;; \t to align prefixes. `(display (space :align-to ,column))) nil)))) (setq first nil) |