[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3c6790f 387/399: ivy.el (ivy-immediate-done): Improve make
From: |
Oleh Krehel |
Subject: |
[elpa] master 3c6790f 387/399: ivy.el (ivy-immediate-done): Improve make-directory |
Date: |
Sat, 20 Jul 2019 14:58:05 -0400 (EDT) |
branch: master
commit 3c6790f846d0d57925cfdbe11f644eb290ab89fa
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-immediate-done): Improve make-directory
1. Don't modify (ivy-state-def ivy-last).
2. "C-M-j" with no input should return (ivy-state-def ivy-last).
3. Update the test, since `read-file-name-default' will detect that
the same (eq) string was returned and return "" instead of the file
name.
4. Add a test that `ivy-read' actually returned the file name.
Re #1170
Re #1719
Fixes #2139
---
ivy-test.el | 19 +++++++++++++------
ivy.el | 22 ++++++++--------------
2 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/ivy-test.el b/ivy-test.el
index 8cea339..6566279 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -971,15 +971,22 @@ will bring the behavior in line with the newer Emacsen."
a buffer visiting a file."
(let ((ivy-mode-reset-arg (if ivy-mode 1 0)))
(ivy-mode 1)
+ ;; `ivy-read' returns "~/dummy-dir/dummy-file" (same object, not a copy).
+ ;;
+ ;; `read-file-name-default' will then return "" in order for
+ ;; `set-visited-file-name' to detect that the user typed RET with
+ ;; the minibuffer empty.
(should
- (equal "~/dummy-dir/dummy-file" ;visiting file name, abbreviated form
- (ivy-with
+ (equal (ivy-with
'(let ((insert-default-directory t))
- (with-temp-buffer
- (set-visited-file-name "~/dummy-dir/dummy-file")
- (read-file-name "Load file: " nil nil 'lambda))) ;load-file
+ (with-temp-buffer
+ (set-visited-file-name "~/dummy-dir/dummy-file")
+ (read-file-name "Load file: " nil nil 'lambda)))
;; No editing, just command ivy-immediate-done
- "C-M-j")))
+ "C-M-j")
+ ""))
+ (should
+ (equal (ivy-state-current ivy-last) "~/dummy-dir/dummy-file"))
(ivy-mode ivy-mode-reset-arg)))
(ert-deftest ivy-starts-with-dotslash ()
diff --git a/ivy.el b/ivy.el
index 21c317c..a015275 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1125,14 +1125,8 @@ If the text hasn't changed as a result, forward to
`ivy-alt-done'."
((and (string= ivy-text "")
(eq (ivy-state-collection ivy-last)
#'read-file-name-internal))
- ;; For `read-file-name' compat, unchanged initial input means
- ;; that `ivy-read' shall return INITIAL-INPUT.
- ;; `read-file-name-default' `string-equal' return value with
- ;; provided INITIAL-INPUT to detect that the user choose the
- ;; default, `default-filename'. We must return
`ivy--directory'
- ;; in unchanged form in cased `ivy--directory' started out as
- ;; INITIAL-INPUT in abbreviated form.
- ivy--directory) ; Unchanged (unexpanded)
+ (or (ivy-state-def ivy-last)
+ ivy--directory))
(t
(expand-file-name ivy-text ivy--directory))))
(insert (ivy-state-current ivy-last))
@@ -2023,10 +2017,10 @@ customizations apply to the current completion session."
(car ivy--all-candidates))
(setq ivy-exit 'done))
(read-from-minibuffer
- prompt
- (ivy-state-initial-input ivy-last)
- (make-composed-keymap keymap ivy-minibuffer-map)
- nil
+ prompt
+ (ivy-state-initial-input ivy-last)
+ (make-composed-keymap keymap ivy-minibuffer-map)
+ nil
hist))
(when (eq ivy-exit 'done)
(let ((item (if ivy--directory
@@ -2120,14 +2114,14 @@ This is useful for recursive `ivy-read'."
(require 'tramp)
(when (and (equal def initial-input)
(member "./" ivy-extra-directories))
- (setf (ivy-state-def state) (setq def nil)))
+ (setq def nil))
(setq ivy--directory default-directory)
(when (and initial-input
(not (equal initial-input "")))
(cond ((file-directory-p initial-input)
(when (equal (file-name-nondirectory initial-input) "")
(setf (ivy-state-preselect state) (setq preselect nil))
- (setf (ivy-state-def state) (setq def nil)))
+ (setq def nil))
(setq ivy--directory (file-name-as-directory
initial-input))
(setq initial-input nil)
(when preselect
- [elpa] master 3ec81dc 369/399: ivy-test.el (swiper--re-builder-char-fold): Split away, (continued)
- [elpa] master 3ec81dc 369/399: ivy-test.el (swiper--re-builder-char-fold): Split away, Oleh Krehel, 2019/07/20
- [elpa] master 98127be 375/399: ivy.el (ivy-format-functions-alist): Fix defcustom type, Oleh Krehel, 2019/07/20
- [elpa] master 1bb48ae 376/399: swiper.el: Add :group for faces, Oleh Krehel, 2019/07/20
- [elpa] master 3380b6f 382/399: swiper.el (swiper--avy-goto): Works for swiper-isearch, Oleh Krehel, 2019/07/20
- [elpa] master bd53ada 379/399: counsel.el (counsel-async-split-string-re-alist): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 0703a70 380/399: counsel.el (counsel-async-ignore-re-alist): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 59603df 383/399: swiper.el (swiper--avy-goto): Fix for a small amount of cands, Oleh Krehel, 2019/07/20
- [elpa] master 5f030d5 381/399: counsel.el (counsel--git-log-format-function): Add, Oleh Krehel, 2019/07/20
- [elpa] master c4c6068 384/399: doc/ivy.org: Fix RET -> C-j, Oleh Krehel, 2019/07/20
- [elpa] master ee5dacf 385/399: Add swiper-backward command, Oleh Krehel, 2019/07/20
- [elpa] master 3c6790f 387/399: ivy.el (ivy-immediate-done): Improve make-directory,
Oleh Krehel <=
- [elpa] master 6e50ab6 391/399: ivy-test.el (swiper-isearch-backward): Goto old match on DEL, Oleh Krehel, 2019/07/20
- [elpa] master 714911b 389/399: ivy.el (ivy--sort): Higher priority for ivy-sort-matches-functions-alist, Oleh Krehel, 2019/07/20
- [elpa] master 56a1f7d 386/399: Add counsel-grep-backward and counsel-grep-or-swiper-backward commands, Oleh Krehel, 2019/07/20
- [elpa] master 79de883 388/399: ivy.el (ivy--sort): Simplify, Oleh Krehel, 2019/07/20
- [elpa] master f5508e5 390/399: swiper.el (swiper-isearch-backward): Add backward search, Oleh Krehel, 2019/07/20
- [elpa] master af0799a 393/399: counsel.el (counsel-git-log-show-commit-action): Fix match end., Oleh Krehel, 2019/07/20
- [elpa] master 54d1b19 392/399: swiper.el (swiper-isearch-action): Use swiper-action-recenter, Oleh Krehel, 2019/07/20
- [elpa] master 16486d5 394/399: ivy.el (ivy--shorter-matches-first): Add and use for ivy-completion-in-region, Oleh Krehel, 2019/07/20
- [elpa] master f99f13a 396/399: Increase swiper-isearch cursor overlay priority, Oleh Krehel, 2019/07/20
- [elpa] master b5db0aa 397/399: ivy.el (ivy--insert-prompt): Adjust ivy-use-selectable-prompt, Oleh Krehel, 2019/07/20