光标在绝对路经之上跳转 续

光标在绝对路经之上跳转 续.

Emacs-lisp Mode 中发现 M-. M-, 很好用.

上次学到了 find-file-at-point, 但是跳回来就不知道了.

这次把 find-file-at-point 瞎折腾了一下,发现能用了.

*** tweak-find-file-at-point	Sat Jul 13 18:01:14 2019
--- find-file-at-point	        Sat Jul 13 17:59:49 2019
***************
*** 1,4 ****
! (defun tweak-find-file-at-point (&optional filename)
    "Find FILENAME, guessing a default from text around point.
  If `ffap-url-regexp' is not nil, the FILENAME may also be an URL.
  With a prefix, this command behaves exactly like `ffap-file-finder'.
--- 1,4 ----
! (defun find-file-at-point (&optional filename)
    "Find FILENAME, guessing a default from text around point.
  If `ffap-url-regexp' is not nil, the FILENAME may also be an URL.
  With a prefix, this command behaves exactly like `ffap-file-finder'.
***************
*** 32,41 ****
         ((or (not ffap-newfile-prompt)
  	    (file-exists-p filename)
  	    (y-or-n-p "File does not exist, create buffer? "))
!         (xref-push-marker-stack)
!         (funcall ffap-file-finder
  		 ;; expand-file-name fixes "~/~/.emacs" bug sent by CHUCKR.
 		 (expand-file-name filename)))
         ;; User does not want to find a non-existent file:
         ((signal 'file-missing (list "Opening file buffer"
  				    "No such file or directory"
--- 32,40 ----
         ((or (not ffap-newfile-prompt)
  	    (file-exists-p filename)
  	    (y-or-n-p "File does not exist, create buffer? "))
! 	(funcall ffap-file-finder
  		 ;; expand-file-name fixes "~/~/.emacs" bug sent by CHUCKR.
 		 (expand-file-name filename)))
         ;; User does not want to find a non-existent file:
         ((signal 'file-missing (list "Opening file buffer"
  				    "No such file or directory"

目前觉得 helm-find-files 最能满足我的需要。有些特殊场景加个 advice

(advice-add 'helm-find-files :before
            (lambda (&rest _)
              (xref-push-marker-stack)))

或者用 next-buffer previous-buffer 来寻找 buffer.

可以用find-file-in-project-at-point. 见 find-file-in-project-at-point doesn't handle full paths · Issue #97 · redguardtoo/find-file-in-project · GitHub

都做好了,不用任何设置。

1 个赞