在使用projectile中的C-c p g 快捷键进入指定目录如何返回上次位置

hi,各位 emacs 道友大家好,最近在使用 projectile做项目管理工具,用ctags找代码提示和跳转,在使用projectile 自带的 C-c p g 进入指定的文件后发现跳不回来了,请问各位道友如何才能做到像 eclipse 那样从一个文件跳转到另一个文件后可以按 Ctrl + left or Ctrl + right 实现在切换过的文件中跳转?

请用describe-key找到按键对应执行的函数,光靠一个键名没法到底执行了什么。

一般执行 xref-pop-marker-stack 可以返回, 默认按键是 M-,

试了下,这个不行啊。

我看了,调用的是 : (helm-projectile-find-file-dwim) 这个方法。

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

在执行命令前push一个marker到栈里就可以用M-,跳回去了。

两个buffer之间切换可以用

(defun cm/alternate-buffer (&optional window)
  "Switch back and forth between current and last buffer in the
current window."
  (interactive)
  (let ((current-buffer (window-buffer window)))
    ;; if no window is found in the windows history, `switch-to-buffer' will
    ;; default to calling `other-buffer'.
    (switch-to-buffer
     (cl-find-if (lambda (buffer)
                   (not (eq buffer current-buffer)))
                 (mapcar #'car (window-prev-buffers window))) nil t)))
2 个赞

不错,你这两个方法的确可以解决问题,但是我现在想做成即可以前进又可以后退,就像 eclipse 中的 alt+ left,alt+right 功能该如何处理呢?