Emacs智能家居

编程入门 行业动态 更新时间:2024-10-23 16:26:21
本文介绍了Emacs智能家居的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 你可以在Emacs的home键中有智慧的行为吗?智能我的意思是,而不是去角色号码0,它应该去第一个非空白字符,并转到0一秒钟按,然后回到第一个非空白的第三个等等。 聪明的结局也会很好。

解决方案

(defun smart -beginning-of-line()将点移动到第一个非空格字符或行首。 将该点移动到此行上的第一个非空格字符。$ (interactive^);在Emacs 22或更旧的中使用(交互式)(let((oldpos(point) ))(back-to-indentation)(和(= oldpos(point))(begin-of-line)))) global-set-key [home]'smart-beginning-of-line)

我不是相当确定智能端将做什么。你通常会有很多尾随的空白?

注意:这个功能与罗伯特·维科维奇之间的主要区别在于他总是移动到第一个按键上的第一个非空白字符,即使光标已经存在。在这种情况下,我会移动到第0列。

此外,他使用(开始的行文本)我使用(back-to-indentation)。这些都非常相似,但它们之间有一些区别。 (back-to-indentation)总是移动到一行上的第一个非空格字符。 (起始行文本)有时会移动它认为不重要的非空格字符。例如,在仅注释行上,它移动到注释文本的第一个字符,而不是注释标记。但是,根据您喜欢的行为,任一功能都可以用于我们的任何一个答案。

Can you have smart behavior for the home key in Emacs? By smart I mean that instead of going to the character number 0, it should go to the first non-blank character, and go to 0 on a second pressing, and back to the first non-blank in a third and so on. Having smart end would be nice as well.

解决方案

(defun smart-beginning-of-line () "Move point to first non-whitespace character or beginning-of-line. Move point to the first non-whitespace character on this line. If point was already at that position, move point to beginning of line." (interactive "^") ; Use (interactive) in Emacs 22 or older (let ((oldpos (point))) (back-to-indentation) (and (= oldpos (point)) (beginning-of-line)))) (global-set-key [home] 'smart-beginning-of-line)

I'm not quite sure what smart end would do. Do you normally have a lot of trailing whitespace?

Note: The major difference between this function and Robert Vuković's is that his always moves to the first non-blank character on the first keypress, even if the cursor was already there. Mine would move to column 0 in that case.

Also, he used (beginning-of-line-text) where I used (back-to-indentation). Those are very similar, but there are some differences between them. (back-to-indentation) always moves to the first non-whitespace character on a line. (beginning-of-line-text) sometimes moves past non-whitespace characters that it considers insignificant. For instance, on a comment-only line, it moves to the first character of the comment's text, not the comment marker. But either function could be used in either of our answers, depending on which behavior you prefer.

更多推荐

Emacs智能家居

本文发布于:2023-11-28 06:49:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641358.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:智能家居   Emacs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!