我已经使用emacs多年了,但绝不是一个专家。当我获得Ubuntu的新版本时,我得到了最新版本的emacs (24),但我不喜欢它,所以回到了emacs23。这就像我习惯的那样,除了查找和替换函数不像我想要的那样工作。我习惯于在文档中的任何地方,点击M %,然后键入我的搜索和替换字符串,点击enter,并在文档的其余部分进行替换。它不再那么做了。如果我不选择一个区域,它甚至不会试图找到任何实例。如果我选择了一个区域,并且它在我的窗口中完全可见,它将进行搜索和替换。如果我突出显示了一个比我的窗口更大的区域,它只会搜索和替换该区域的可见区域。这太令人恼火了。
我认为这与“临时标记模式”有关,这显然是在emacs23中默认的,人们描述我所看到的行为。但是,当我用my临时标记模式或在我的.emacs文件中关闭它时,没有什么变化。我做错了什么?
发布于 2014-12-10 11:14:45
我无法复制您的问题,但可能是您启用了cua模式,并防止关闭瞬态标记模式。尝试切换M-x cua-mode,直到禁用为止,然后切换M-x transient-mark-mode,直到禁用为止。然后检查这是否解决了你的问题。
顺便提一句,我觉得很奇怪,您喜欢Emacs23 (因为您已经使用它多年了),并且讨厌Emacs24。当你尝试Emacs24时出了什么问题?
下面是query-replace-regexp-to-the-end-of-buffer-or-in-a-region defun,它可以做您想做的事情:
(defun query-replace-regexp-to-the-end-of-buffer-or-in-a-region (point)
"If there's a region - query replaces regexp in region,
otherwise replaces from current point to the end of buffer."
(interactive "d")
(let (start end)
(if (use-region-p)
(progn (setq start (region-beginning)) ;; then
(setq end (region-end)))
(progn (setq start point) ;; else
(setq end (point-max))))
(set-mark start)
(goto-char end)
(apply #'query-replace-regexp
(let ((common (query-replace-read-args (concat "Query replace regexp") t)))
(list (nth 0 common) (nth 1 common) (nth 2 common) (if (and transient-mark-mode mark-active) (region-beginning)) (if (and transient-mark-mode mark-active) (region-end)))))))只需将其绑定到某个密钥,甚至可以绑定到M-%。
https://askubuntu.com/questions/554472
复制相似问题