2010-08-18 47 views
3

升级从Emacs的21.2至23.2的挑战继续...在我的.emacs我有很方便的:Emacs 23.2中dired-omit-toggle在哪里消失?

(global-set-key (quote [f4]) (quote dired-omit-toggle)) 

它曾经因为Emacs的18工作...但它不再在Emacs 23.2作品:

Lisp error: (void-function dired-omit-toggle)

任何想法如何在Emacs 23.2中替换此功能?

EmacsWiki说:

To use this mode add the following to your InitFile.

(add-hook 'dired-load-hook 
      (function (lambda() (load "dired-x")))) 

,这是我一直有这些年到底是什么。但Emacs 23.2不再喜欢这个了。任何想法可以取代它在Emacs 23.2?

回答

3

由于Emacs 22,您需要拨打dired-omit-mode而不是dired-omit-toggle。您仍然需要加载dired-x。从NEWS.22

*** In Dired-x, Omitting files is now a minor mode, dired-omit-mode.

The mode toggling command is bound to M-o. A new command dired-mark-omitted, bound to * O, marks omitted files. The variable dired-omit-files-p is obsoleted, use the mode toggling function instead.

+0

吉尔斯,你是一个生命的救星。看起来我面临的挑战源于我没有经历过Emacs 22的事实,所以它的NEWS文件不适合Emacs 23我正在尝试为我工作。无论如何,你的建议工作。我将很快发布代替它的代码。 – 2010-08-18 22:44:22

0

因为我从Emacs的21升级到23是渐进的,必须维护好系统,其中一些使用Emacs 21,和一些使用Emacs的23相同的.emacs,我想出了下面的代码:

(GNUEmacs21 
(global-set-key (quote [f4]) (quote dired-omit-toggle)) 
) 

(GNUEmacs22 
(global-set-key (quote [f4]) (quote dired-omit-mode)) 
) 

(GNUEmacs23 
(global-set-key (quote [f4]) (quote dired-omit-mode)) 
) 

GNUEmacs21,GNUEmacs22和GNUEmacs23出现在靠前的.emacs文件的定义:

(defmacro GNUEmacs23 (&rest body) 
    (list 'if (string-match "GNU Emacs 23" (version)) 
     (cons 'progn body))) 

(defmacro GNUEmacs22 (&rest body) 
    (list 'if (string-match "GNU Emacs 22" (version)) 
     (cons 'progn body))) 

(defmacro GNUEmacs21 (&rest body) 
    (list 'if (string-match "GNU Emacs 21" (version)) 
     (cons 'progn body))) 
+2

我不建议走这条路线,因为你必须弄清楚Emacs的哪个版本改变了这个功能。通过测试函数或变量的可用性可以最好地解决大多数这种不兼容问题。在这里,我会做一些类似'(加载后评估“dired-x”'(if(not(fboundp'dired-omit-toggle))(defalias'dired-omit-toggle'dired-omit-mode)) )'。 – Gilles 2010-08-18 23:03:58

+0

优秀的建议。谢谢! – 2010-08-19 03:06:49