Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

counsel-find-file-at-point now requires hitting M-n after C-x C-f #515

Closed
kaushalmodi opened this Issue May 20, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@kaushalmodi
Copy link
Contributor

commented May 20, 2016

Hi,

After the recent commit ( 8c7a7fc ), the counsel-find-file-at-point behavior stopped working like before.

Now for the "ffap" feature to work, I need to do C-x C-f followed by M-n. Earlier that M-n step was not required.

I tested it in emacs -Q by just adding the required Melpa installed packages to the load path

(progn
  (add-to-list 'load-path "/home/kmodi/.emacs.d/elpa_25_0/swiper-20160510.2311/")
  (add-to-list 'load-path "/home/kmodi/.emacs.d/elpa_25_0/counsel-20160519.744/")
  (add-to-list 'load-path "/home/kmodi/.emacs.d/elpa_25_0/ivy-20160520.218/")

  (require 'counsel)
  (setq counsel-find-file-at-point t)
  (global-set-key (kbd "C-x C-f") #'counsel-find-file))

Reverting this commit fixes this for me.

So the fix is to add ffap-guesser's output to initial-input instead of to preselect?

@kaushalmodi kaushalmodi changed the title counsel-find-file-at-point counsel-find-file-at-point now requires hitting M-n after C-x C-f May 20, 2016

@kaushalmodi

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2016

This seems to work but then I do not know the full implications of removing :preselect and ignoring the optional arg initial-input:

(defun counsel-find-file (&optional initial-input)
  "Forward to `find-file'.
When INITIAL-INPUT is non-nil, use it in the minibuffer during completion."
  (interactive)
  (ivy-read "Find file: " 'read-file-name-internal
            :matcher #'counsel--find-file-matcher
            :initial-input (when counsel-find-file-at-point
                             (require 'ffap)
                             (let ((f (ffap-guesser)))
                               (when f (expand-file-name f))))
            :action (lambda (x)
                      (with-ivy-window
                        (find-file (expand-file-name x ivy--directory))))
            :require-match 'confirm-after-completion
            :history 'file-name-history
            :keymap counsel-find-file-map
            :caller 'counsel-find-file))

@abo-abo abo-abo closed this in 5820db3 May 21, 2016

@abo-abo

This comment has been minimized.

Copy link
Owner

commented May 21, 2016

Fixed, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.