[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-27 fe0ed17 2/7: Slightly simplify lisp/icomplete.el with new icomp
From: |
Jo�o T�vora |
Subject: |
emacs-27 fe0ed17 2/7: Slightly simplify lisp/icomplete.el with new icomplete--category helper |
Date: |
Tue, 31 Dec 2019 08:32:04 -0500 (EST) |
branch: emacs-27
commit fe0ed17175306dbcd3217e98fd84af2c2e077ce8
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Slightly simplify lisp/icomplete.el with new icomplete--category helper
* lisp/icomplete.el (icomplete-fido-kill)
(icomplete-fido-delete-char, icomplete-fido-ret)
(icomplete-fido-backward-updir, icomplete-exhibit): Use
icomplete--category.
(icomplete--category): New helper.
(cherry picked from commit 24a1f520f91c278cb8cc57325ea80285a3b252cf)
---
lisp/icomplete.el | 39 +++++++++++++++------------------------
1 file changed, 15 insertions(+), 24 deletions(-)
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index cd20064..4d6dfcd 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -234,15 +234,13 @@ completed. If completing files, it means delete the
file. If
completing buffers it means kill the buffer. Both actions
require user confirmation."
(interactive)
- (let ((beg (icomplete--field-beg)) (end (icomplete--field-end)))
+ (let ((end (icomplete--field-end)))
(if (< (point) end)
(call-interactively 'kill-line)
- (let* ((md (completion--field-metadata beg))
- (category (alist-get 'category (cdr md)))
- (all (completion-all-sorted-completions))
+ (let* ((all (completion-all-sorted-completions))
(thing (car all))
(action
- (pcase category
+ (pcase (icomplete--category)
(`buffer
(lambda ()
(when (yes-or-no-p (concat "Kill buffer " thing "? "))
@@ -267,11 +265,8 @@ require user confirmation."
(defun icomplete-fido-delete-char ()
"Delete char or maybe call `dired', like `ido-mode'."
(interactive)
- (let* ((beg (icomplete--field-beg))
- (end (icomplete--field-end))
- (md (completion--field-metadata beg))
- (category (alist-get 'category (cdr md))))
- (if (or (< (point) end) (not (eq category 'file)))
+ (let ((end (icomplete--field-end)))
+ (if (or (< (point) end) (not (eq (icomplete--category) 'file)))
(call-interactively 'delete-char)
(dired (file-name-directory (icomplete--field-string)))
(exit-minibuffer))))
@@ -279,10 +274,7 @@ require user confirmation."
(defun icomplete-fido-ret ()
"Exit minibuffer or enter directory, like `ido-mode'."
(interactive)
- (let* ((beg (icomplete--field-beg))
- (md (completion--field-metadata beg))
- (category (alist-get 'category (cdr md)))
- (dir (and (eq category 'file)
+ (let* ((dir (and (eq (icomplete--category) 'file)
(file-name-directory (icomplete--field-string))))
(current (car (completion-all-sorted-completions)))
(probe (and dir current
@@ -297,12 +289,10 @@ require user confirmation."
(defun icomplete-fido-backward-updir ()
"Delete char before or go up directory, like `ido-mode'."
(interactive)
- (let* ((beg (icomplete--field-beg))
- (md (completion--field-metadata beg))
- (category (alist-get 'category (cdr md))))
- (if (and (eq (char-before) ?/) (eq category 'file))
- (backward-kill-sexp 1)
- (call-interactively 'backward-delete-char))))
+ (if (and (eq (char-before) ?/)
+ (eq (icomplete--category) 'file))
+ (backward-kill-sexp 1)
+ (call-interactively 'backward-delete-char)))
(defvar icomplete-fido-mode-map
(let ((map (make-sparse-keymap)))
@@ -392,6 +382,10 @@ completions:
(defun icomplete--field-end ()
(if (window-minibuffer-p) (point-max)
(nth 1 completion-in-region--data)))
+(defun icomplete--category ()
+ (let* ((beg (icomplete--field-beg))
+ (md (completion--field-metadata beg)))
+ (alist-get 'category (cdr md))))
;;;_ > icomplete-simple-completing-p ()
(defun icomplete-simple-completing-p ()
@@ -488,10 +482,7 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
(sit-for icomplete-compute-delay)))
(when (and
icomplete-tidy-shadowed-file-names
- (eq (alist-get 'category
- (cdr (completion--field-metadata
- (icomplete--field-beg))))
- 'file)
+ (eq (icomplete--category) 'file)
rfn-eshadow-overlay (overlay-buffer rfn-eshadow-overlay)
(eq this-command 'self-insert-command)
(= saved-point (icomplete--field-end))
- emacs-27 updated (9b6872b -> 195bde9), Jo�o T�vora, 2019/12/31
- emacs-27 5352947 1/7: Another adjustment to flex completion style's sorting function, Jo�o T�vora, 2019/12/31
- emacs-27 e3276f3 3/7: Make fido-mode behave more like ido-mode when finding directories, Jo�o T�vora, 2019/12/31
- emacs-27 b1c3ed9 4/7: Move flex style's minibuffer-default-aware sorting to lisp/icomplete.el, Jo�o T�vora, 2019/12/31
- emacs-27 9b1053b 5/7: Correctly cache sorted completions in icomplete--sorted-completions, Jo�o T�vora, 2019/12/31
- emacs-27 fe0ed17 2/7: Slightly simplify lisp/icomplete.el with new icomplete--category helper,
Jo�o T�vora <=
- emacs-27 f2a349b 6/7: Don't force completion recalculation in icomplete-fido-ret, Jo�o T�vora, 2019/12/31
- emacs-27 195bde9 7/7: Don't always resort in recently introduced icomplete--sorted-completions, Jo�o T�vora, 2019/12/31