我有一个自定义函数,如果标记了多个标记文件名(即每个标记文件的名称),或者如果只有一个标记文件名,则它获取文件名。当光标位于 no-man's-land 时会出现问题,因为dired-mark
(或我,因为我是飞行员)在重复时过度热心并将光标移动到空行处缓冲区末尾没有文件。在这种情况下,错误如下:
Debugger entered--Lisp error: (error "No file on this line")
signal(error ("No file on this line"))
error("No file on this line")
dired-get-file-for-visit()
(file-directory-p (dired-get-file-for-visit))
(if (file-directory-p (dired-get-file-for-visit)) nil (let ((lawlist-filename (if (or (re-search-backward "^*" nil t) (re-search-forward "^*" nil t)) (dired-get-marked-files) (dired-get-file-for-visit)))) (wl-draft-mailto) (attach-multiple-files lawlist-filename)))
(lambda nil (interactive) (if (file-directory-p (dired-get-file-for-visit)) nil (let ((lawlist-filename (if (or (re-search-backward "^*" nil t) (re-search-forward "^*" nil t)) (dired-get-marked-files) (dired-get-file-for-visit)))) (wl-draft-mailto) (attach-multiple-files lawlist-filename))))()
funcall-interactively((lambda nil (interactive) (if (file-directory-p (dired-get-file-for-visit)) nil (let ((lawlist-filename (if (or (re-search-backward "^*" nil t) (re-search-forward "^*" nil t)) (dired-get-marked-files) (dired-get-file-for-visit)))) (wl-draft-mailto) (attach-multiple-files lawlist-filename)))))
call-interactively((lambda nil (interactive) (if (file-directory-p (dired-get-file-for-visit)) nil (let ((lawlist-filename (if (or (re-search-backward "^*" nil t) (re-search-forward "^*" nil t)) (dired-get-marked-files) (dired-get-file-for-visit)))) (wl-draft-mailto) (attach-multiple-files lawlist-filename)))) nil nil)
command-execute((lambda nil (interactive) (if (file-directory-p (dired-get-file-for-visit)) nil (let ((lawlist-filename (if (or (re-search-backward "^*" nil t) (re-search-forward "^*" nil t)) (dired-get-marked-files) (dired-get-file-for-visit)))) (wl-draft-mailto) (attach-multiple-files lawlist-filename)))))
我喜欢将dired-mark
键保持为重复的能力,但我希望它在dired-mode缓冲区中的文件的最后一行停止。任何关于如何实现这一目标的想法都将不胜感激。超过这一点,执行测试,然后返回到上一点似乎不是一种非常有效的处理方法。最好用文件终止最后一行末尾的dired缓冲区,这样就没有空白行 - 也就是说,如果在dired-mode缓冲区的末尾没有空行,那么{{ 1}}不能去那里(这样会好吗?)。
编辑:调试器消息已更新为完整的回溯。以下是自定义函数,正如@Drew建议的那样,可能是我收到的错误消息的根本原因:
dired-mark
答案 0 :(得分:0)
在defadvice
上尝试dired-mark
以避免在无人区登陆:
(defadvice dired-mark (after stop-at-last-file activate)
(when (eobp)
(previous-line 1)))
“标记后向前移动”功能被烘焙到dired-mark
(实际上,如果你想进入它的内部,进入dired-repeat-over-lines
),所以这个建议检查它是否会让你那个空白行,如果是这样就会让你回头。你的最后一段暗示你可能不会对这个选项非常热衷,但它让我觉得比改变可怕的内部结构更麻烦。
答案 1 :(得分:0)
上一个答案(2014年10月17日):如果光标不在文件或目录上并且没有标记任何内容,则以下3行代码将暂停该功能:
(when (null (dired-get-marked-files))
(let ((debug-on-quit nil))
(signal 'quit `("You are not on a line containing a valid file or directory."))))
修订后的答案(2015年1月20日):可以修改函数dired-insert-directory
以删除缓冲区末尾的尾随新行和/或空格,如下所示:
(goto-char (point-max))
(let ((trailing-whitespace+newlines (abs (skip-chars-backward "\s\r\n\t"))))
(when (> trailing-whitespace+newlines 0)
(delete-char trailing-whitespace+newlines)))