2013-06-03 57 views
2

我想定義Emacs命令的修改版本,例如browse-url如何定義包裝器命令?

修改後的版本應綁定一些變量,然後推遲到系統命令,例如,

(defun browse-url-incognito (url &rest args) 
    ??? 
    (let ((browse-url-browser-function 'browse-url-generic) 
     (browse-url-generic-program "google-chrome") 
     (browse-url-generic-args '("--incognito"))) 
    (apply 'browse-url url args))) 

問題是與應該將功能到交互式命令的???一部分。

我可以,當然,從browse-url.el拷貝過來的代碼:

(interactive (browse-url-interactive-arg "URL: ")) 
    (unless (called-interactively-p 'interactive) 
    (setq args (or args (list browse-url-new-window-flag)))) 

但這種感覺就像作弊(更不用提讓我的代碼脆弱)。

回答

4

call-interactively似乎買單:

(defun browse-url-incognito() 
    "Call `browse-url' displaying in a chrome incognito window." 
    (interactive) 
    (let ((browse-url-browser-function 'browse-url-generic) 
     (browse-url-generic-program "google-chrome") 
     (browse-url-generic-args '("--incognito"))) 
    (call-interactively 'browse-url)))