0

如何在 Emacs ESS 模式下高效编程是关键

"<"     "[less than]"

"<- "   "[less than][dash][space]"   

就像 R 的 MacOS 版本一样。

4

2 回答 2

2

看起来文件中有一个现有的函数ess-s-l.el。看来您可以ess-S-assign-key为此使用变量:

;; This is by Seth Falcon, modeled after ess-toggle-underscore (see below).
(defun ess-toggle-S-assign-key (force)
  "Possibly bind the key in `ess-S-assign-key' to inserting `ess-S-assign'.
If `ess-S-assign-key' is \"_\", simply use \\[ess-toggle-underscore].
Otherwise, unless the prefix argument FORCE is set,
toggle between the new and the previous assignment."
  (interactive "P")
  (require 'ess-mode)
  (require 'ess-inf)
  (let ((current-action (lookup-key ess-mode-map ess-S-assign-key))
        (insert-S-assign (lambda() (interactive)
                           (delete-horizontal-space) (insert ess-S-assign))))
    (if (and (stringp ess-S-assign-key)
             (string= ess-S-assign-key "_"))
        (ess-toggle-underscore force)
      ;; else "do things here"
      (let* ((current-is-S-assign (eq current-action insert-S-assign))
             (new-action (if force insert-S-assign
                           ;; else "not force" (default):
                           (if (or current-is-S-assign
                                   (eq ess-S-assign-key-last insert-S-assign))
                               ess-S-assign-key-last
                             insert-S-assign))))
        (message "[ess-toggle-S-assign-key:] current: '%s', new: '%s'"
                 current-action new-action)
        (define-key ess-mode-map          ess-S-assign-key new-action)
        (define-key inferior-ess-mode-map ess-S-assign-key new-action)
        (if (not (and force current-is-S-assign))
            (setq ess-S-assign-key-last current-action))))))
于 2012-08-27T18:05:40.343 回答
1

也许这取决于 ESS 版本。

在我的 ESS (12.03) 版本中,您似乎可以绑定">"'ess-insert-S-assign以获得您喜欢的内容。

查看ess-可供您使用的命令(M-x ess-<TAB><TAB>并在*Completions*刚刚弹出的缓冲区中搜索assign),看看哪个命令可能是您应该绑定的罪魁祸首">"

如果这对您不起作用——也许您可能需要升级。

于 2012-08-29T10:15:33.837 回答