Emacs;C-x C-j在加载dired之前,dired-x
试图减少我的Emacs;C-x C-j在加载dired之前,dired-x,emacs,require,autoload,dired,Emacs,Require,Autoload,Dired,试图减少我的init.el中的requires的数量 然而,在dired-x中,有一个可怕的C-xc-j=dired跳转,它跳转到当前缓冲区的目录。即使我们还没有加载dired和dired-x,想要使用C-xc-j也是很自然的。但它是未定义的 如何和解 换句话说,我遇到这个问题是因为我正在试验以下混合物: (setq-default dired-omit-files-p t) ; The old way was messy (setq dired-omit-files "^\\
init.el
中的require
s的数量
然而,在dired-x
中,有一个可怕的C-xc-j
=dired跳转
,它跳转到当前缓冲区的目录。即使我们还没有加载dired
和dired-x
,想要使用C-xc-j
也是很自然的。但它是未定义的
如何和解
换句话说,我遇到这个问题是因为我正在试验以下混合物:
(setq-default dired-omit-files-p t) ; The old way was messy
(setq dired-omit-files "^\\.?#\\|^\\.$") ; I like `..' in my dired
(setq dired-details-hidden-string "")
(add-hook 'dired-load-hook
(lambda ()
(load "dired-x")
(when (locate-library "dired-details")
(load "dired-details")
(dired-details-install)
)
))
我想知道是否有一个神奇的自动加载功能,虽然我真的不明白这些。也就是说,在dired-x.el
中,我发现
;;;###autoload
(defun dired-jump ...
但事实上,这些都有点超出我的头脑,所以我放弃了它
我提出了一个“更简单”的解决方案,本来打算删除这个,但有一种感觉,其他人会喜欢这个,所以我会为你提问和回答。欢迎评论和其他策略 以下简单解决方案仅定义了
C-x C-j
,但一旦加载了dired
-和dired-x
,就会被覆盖
;; if dired(-x) is not loaded, C-x C-j is undefined
(defun undefined-c-x-c-j-loads-dired-and-jumps ()
(interactive)
(load "dired")
(dired-jump))
(global-set-key (kbd "C-x C-j") 'undefined-c-x-c-j-loads-dired-and-jumps)
C-hig(dired-x)可选安装dired Jump
RET
为了使直接跳转
和直接跳转其他窗口
(*注意
杂项命令::)在执行dired
和dired-x
之前工作
正确加载您应该为这些功能设置自动加载。在里面
您的.emacs
文件已放入
我不确定为什么
dired-x
库与默认功能保持分离。那是###自动加载
cookie只有在Emacs构建过程查看它时才会起作用(由此类注释生成的自动加载语句通常会在一个loaddefs.el
文件中结束),因此很明显,这并没有发生(可能是故意的,但你的猜测和我的猜测一样好,原因是什么)。谢谢你。。。我认为我的解决方案有太多的潜力破坏事物。我更喜欢这样的行,它们对init文件的更改和重新排序更具弹性。考虑到lisp的小更改或重新排序,这种解决方案可能无法很好地工作。这是自动加载的一种幼稚实现。@event_jr,啊,我想我明白你的意思了,特别是如果我的重新定义是关于dired
或dired-x
,而不是键绑定。我将试着证明在我的配置中保持一个小的编辑作为练习是正当的。谢谢你的观察!
(autoload 'dired-jump "dired-x"
"Jump to Dired buffer corresponding to current buffer." t)
(autoload 'dired-jump-other-window "dired-x"
"Like \\[dired-jump] (dired-jump) but in other window." t)
(define-key global-map "\C-x\C-j" 'dired-jump)
(define-key global-map "\C-x4\C-j" 'dired-jump-other-window)