小编Tyl*_*ler的帖子

我曾经使用nano编辑文本,但我切换到vim,这是更强大的.如果我转移到emacs,我会获得相同的电源吗?

大约3年多以来,我认为我需要的所有东西(技术上都是如此)都是nano.在我尝试之前,我并不理解关于vim的所有喧嚣.虽然学习曲线略高,但它大大简化了我的编码,我不会想回到nano.

但是,我已经多次听说过,emacs是最难学的,但却是程序员最有用的编辑器.通过文本编辑器(并发现自己目前正在选择emacs)采取类似的进化路径的任何人都可以告诉我它的优势是什么?

现在我对vim的看法与我之前关于nano的看法是一样的,即:边际效用是否足以证明投入学习的时间是合理的?从nano切换到vim,答案显然是肯定的(对我而言).如果我学习emacs,我会回过头来对vim说同样的话吗?

vim emacs nano

7
推荐指数
1
解决办法
6144
查看次数

检查lisp SLIME调试器中的变量

我试图在确定的断点处检查变量的值.这是我的简化代码:

(defun foo ()
  (maplist (lambda (var)
        (break)
        var)
      '(a b c)))
Run Code Online (Sandbox Code Playgroud)

此时slime进入调试器模式.所以我尝试通过按":"或"e"键来评估,然后输入"(car var)",但是史莱姆继续说:

变量VAR是未绑定的.[UNBOUND-VARIABLE类型的条件]

我很困惑为什么它说这个,因为"(break)"在匿名函数内并且在"var"的范围内.

lisp clisp common-lisp

7
推荐指数
1
解决办法
1001
查看次数

如何在后台执行shell命令?

这是一个简单的defun来运行shell脚本:

(defun bk-konsoles ()
  "Calls: bk-konsoles.bash"
  (interactive)
  (shell-command (concat (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ")
                         (if (buffer-file-name) 
                             (file-name-directory (buffer-file-name)))
                         " &") 
                  nil nil))
Run Code Online (Sandbox Code Playgroud)

如果我启动一个没有&符号的程序 - 它启动脚本,但阻止emacs直到我关闭程序,如果我没有输入&符号它会给出错误:

/home/boris/its/plts/goodies/bk-konsoles.bash /home/boris/scl/geekgeek/: exited abnormally with code 1.
Run Code Online (Sandbox Code Playgroud)

编辑:

所以现在我正在使用:

(defun bk-konsoles ()
  "Calls: bk-konsoles.bash"
  (interactive)
  (shell-command (concat (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ") 
                         (if (buffer-file-name) 
                             (file-name-directory (buffer-file-name))) 
                         " & disown") 
                 nil nil)
  (kill-buffer "*Shell Command Output*"))
Run Code Online (Sandbox Code Playgroud)

编辑2:

不 - 不起作用:

(defun bk-konsoles ()
  "Calls: bk-konsoles.bash"
  (interactive)
  (let ((curDir default-directory))
    ;; (shell-command (concat "nohup " (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ") curDir) …
Run Code Online (Sandbox Code Playgroud)

emacs elisp

5
推荐指数
1
解决办法
3063
查看次数

Emacs完成点功能

我正在编写基于comint-mode的派生模式.该模式是命令行程序(GRASS gis)的接口,并且comint模式完成适用于程序.我正在尝试添加对完成程序参数的支持,通过completion-at-point-functions.一个玩具的例子是:

(setq my-commands 
      '(("ls"
         ("my-completion-1")
         ("my-completion-2"))
        ("mv"
         ("my-completion-3")
         ("my-completion-4"))))


(defun my-completion-at-point ()
  (interactive)
  (let ((pt (point)) ;; collect point
        start end)

    (save-excursion ;; collect the program name
      (comint-bol)
      (re-search-forward "\\(\\S +\\)\\s ?"))
    (if (and (>= pt (match-beginning 1))
             (<= pt (match-end 1)))
        () ;; if we're still entering the command, pass completion on to
      ;; comint-completion-at-point by returning nil

      (let ((command (match-string-no-properties 1)))
        (when (member* command my-commands :test 'string= :key 'car)
          ;; If the command is one …
Run Code Online (Sandbox Code Playgroud)

emacs elisp tab-completion

4
推荐指数
1
解决办法
1754
查看次数

emacs:将 python 空格转换为制表符

目前我在我的 .emacs 文件中使用以下设置:

;; single tab for every indent
(add-hook 'python-mode-hook
  (lambda ()
    (setq indent-tabs-mode t)
    (setq python-indent 4)
    (setq tab-width 4)))
Run Code Online (Sandbox Code Playgroud)

这适用于我创建的任何新文件。如果我从 git/hg 下载一个恰好在空间上的项目,emacs 将不会将它们转换为空间上。无论文件的原始设置是什么,我如何强制 emacs 将所有空格转换为制表符。

我知道如果它是一个 git/hg 存储库,这将创建大量更改集,但我仍然想弄清楚如何通过我的 emacs 设置将任何带有空间的文件转换为选项卡。

python emacs whitespace tabs

4
推荐指数
1
解决办法
2629
查看次数

Emacs 下移窗口

我通过 emacs 打开了多个窗口C-X 2。但是,有时我想将顶部的窗口向下移动一个位置,以便其下面的窗口向上移动,而我想要移动的窗口向下移动一个位置。我不是在谈论在窗口内移动,而是移动实际的窗口。这在 emacs 中可能吗?

emacs

4
推荐指数
1
解决办法
941
查看次数

将R编织为PDF时限制消息输出

我有一个报告进度的功能message().在正常使用下,这是可取的,并且suppressMessages()如果需要,可以通过消息来抑制消息.

但是,我正在编写一个调用此函数的插图(在Rmarkdown中),结果包括这些进度更新的完整页面.我想包括前几行消息,但不要浪费整整一页.有没有办法配置这个?

我已尝试传递chunk选项R.options=list(max.print=10),如此处的另一个答案所示,但这似乎不适用于消息.或者至少,不是在这种情况下,在每个函数内一次生成一个或两个实际消息,但该函数被称为循环的一部分.

我正在使用的一般结构是:

function1 <- function(file.list){
    res <- list()
    for(i in seq_along(file.list)){
        message("processing ", file.list[i])
        res[i] <- function2(file.list[i])
    }
}

function2 <- function(file){
    message("analyzing ", file)
    tryVal <- try(res <- analysisFunction(file), silent = TRUE)
    if(inherits(tryVal, "try-error")){
       message("*** problem with ", file, " ***")
    } else {
      ## additional processing
    }
    return(res)
}
Run Code Online (Sandbox Code Playgroud)

降价块看起来像这样:

```{r batchFlowHist, R.options=list(max.print=10)}
batch1 <- function1(flowPloidyFiles)
```
Run Code Online (Sandbox Code Playgroud)

我希望我的插图能够显示处理的前几个文件中的消息,而不是整个循环.有办法做到这一点吗?

markdown r knitr

4
推荐指数
1
解决办法
199
查看次数

SICP车/ cdr练习题问题

我在这里为SICP尝试这个"在线辅导员":http://icampustutor.csail.mit.edu/6.001-public/tutor.cgi?op = registration-page

我正在看下面的问题:

假设我们已经评估了表单

(define thing (cons (cons (cons 1 nil) nil)
                    (cons (cons 2 (cons 3 (cons 4 nil)))
                          (cons 2
                               (cons 3 nil))))) Write expressions
Run Code Online (Sandbox Code Playgroud)

仅使用car,cdr和其值为下面给出的列表结构的东西.

(1)
1
(2 3)
(3)

我遇到了最后一个问题.我想出了一种使用反引号和非引号的方法,但是在线教程不接受答案.使用鸡计划的翻译:

#;3> (define nil '())
#;4>  (define thing (cons (cons (cons 1 nil) nil)
--->                         (cons (cons 2 (cons 3 (cons 4 nil)))
--->                               (cons 2
--->                                    (cons 3 nil)))))
#;5> 
#;5> thing
(((1)) (2 3 4) 2 3)

#;25> `(,(car(cdr(car(cdr thing)))))
(3)
Run Code Online (Sandbox Code Playgroud)

还有另一种方法吗?

lisp scheme sicp

3
推荐指数
1
解决办法
413
查看次数

R:使用公式绘制矩阵列

在我的代码中花了一个小时追逐'matrix vs data.frame'错误,我非常想了解以下内容:

tmp <-
  structure(c(4L, 7L, 5L, 12L, 6L, 11L, 9L, 3L, 1L, 2L, 10L, 8L),
            .Dim = c(6L, 2L), .Dimnames = list(NULL, c("col1", "col2")))

## 1. This works:
plot(col2 ~ col1, data = tmp)

## 2. This doesn't work:
plot(col2 ~ col1, data = tmp, main = "hello")
## -> Error in FUN(X[[1L]], ...) : numeric 'envir' arg not of length one

## 3. This works:
plot(col2 ~ col1, data = as.data.frame(tmp), main = "hello")
Run Code Online (Sandbox Code Playgroud)

在我看来,1和2都应该工作,或两者都失败.1在2失败的情况下工作的事实导致我在试图使我的代码工作时非常误入歧途.

我的问题是:你为什么有时会 …

r

3
推荐指数
1
解决办法
563
查看次数

在.emacs中设置default-directory

我真的不知道该说些什么.

我一直在努力定制我的emacs,我注意到它实际上并没有.emacs在启动时加载我.根据(http://www.gnu.org/software/emacs/manual/html_node/emacs/Find-Init.html#Find-Init),emacs首先在HOME目录(~/)中查找初始化文件...

当我启动emacs时,我的.emacs文件似乎被正确读取 - .notes例如,当我访问文件时,会对钩子进行评估等等.让我感到惊讶的是:默认目录未设置 - 同一个加载文件中的命令.我可以手动评估它或只是执行(load "~/.emacs")它,它将工作正常.

我想这个问题可以概括一下:如果在load手动执行时命令按预期工作,为什么它不能自动启动?

完整(注释掉函数除外).emacs文件:

; http://stackoverflow.com/a/13946304/1443496
(defvar auto-minor-mode-alist ()
  "Alist of filename patterns vs correpsonding minor mode functions,
   see `auto-mode-alist'. All elements of this alist are checked,
   meaning you can enable multiple minor modes for the same regexp.")

(defun enable-minor-mode-based-on-extension ()
  "check file name against auto-minor-mode-alist to enable minor modes
the checking happens for all pairs in auto-minor-mode-alist"
  (when …
Run Code Online (Sandbox Code Playgroud)

emacs elisp dot-emacs

1
推荐指数
1
解决办法
566
查看次数

标签 统计

emacs ×6

elisp ×3

lisp ×2

r ×2

clisp ×1

common-lisp ×1

dot-emacs ×1

knitr ×1

markdown ×1

nano ×1

python ×1

scheme ×1

sicp ×1

tab-completion ×1

tabs ×1

vim ×1

whitespace ×1