Emacs自定义配置(一):智能复制行,未选定时注释当前行,Copy后智能缩进
来源:互联网 发布:2016上海程序员工资 编辑:程序博客网 时间:2024/06/07 03:38
把下面的代码写入到~/.emacs文件中
;;=====================================================================;;Copy代码段后自动格式化;;=====================================================================(dolist (command '(yank yank-pop)) (eval `(defadvice ,command (after indent-region activate) (and (not current-prefix-arg) (member major-mode '(emacs-lisp-mode lisp-mode clojure-mode scheme-mode haskell-mode ruby-mode rspec-mode python-mode c-mode c++-mode objc-mode latex-mode js-mode plain-tex-mode)) (let ((mark-even-if-inactive transient-mark-mode)) (indent-region (region-beginning) (region-end) nil))))));;=====================================================================;;只能COPY,M+k复制当前行;;=====================================================================(defadvice kill-line (before check-position activate) (if (member major-mode '(emacs-lisp-mode scheme-mode lisp-mode c-mode c++-mode objc-mode js-mode latex-mode plain-tex-mode)) (if (and (eolp) (not (bolp))) (progn (forward-char 1) (just-one-space 0) (backward-char 1))))) (defadvice kill-ring-save (before slick-copy activate compile) "When called interactively with no active region, copy a single line instead." (interactive (if mark-active (list (region-beginning) (region-end)) (message "Copied line") (list (line-beginning-position) (line-beginning-position 2))))) (defadvice kill-region (before slick-cut activate compile) "When called interactively with no active region, kill a single line instead." (interactive (if mark-active (list (region-beginning) (region-end)) (list (line-beginning-position) (line-beginning-position 2))))) ;; Copy line from point to the end, exclude the line break(defun qiang-copy-line (arg) "Copy lines (as many as prefix argument) in the kill ring" (interactive "p") (kill-ring-save (point) (line-end-position)) ;; (line-beginning-position (+ 1 arg))) (message "%d line%s copied" arg (if (= 1 arg) "" "s"))) (global-set-key (kbd "M-k") 'qiang-copy-line);;=====================================================================;;注释当前行"M+;";;=====================================================================(defun qiang-comment-dwim-line (&optional arg) "Replacement for the comment-dwim command.If no region is selected and current line is not blank and we are not at the end of the line,then comment current line.Replaces default behaviour of comment-dwim, when it inserts comment at the end of the line." (interactive "*P") (comment-normalize-vars) (if (and (not (region-active-p)) (not (looking-at "[ \t]*$"))) (comment-or-uncomment-region (line-beginning-position) (line-end-position)) (comment-dwim arg)))(global-set-key "\M-;" 'qiang-comment-dwim-line)
0 0
- Emacs自定义配置(一):智能复制行,未选定时注释当前行,Copy后智能缩进
- emacs复制当前行
- 改变Emacs下的注释代码方式以支持当前行(未选中情况下)的注释/反注释
- 智能语音前行
- Emacs 24.4 配置C++智能提示
- Vim配置 显示行号 语法高亮 智能缩进
- Emacs C++智能提示
- 智能指针(一)
- emacs 当前行高亮显示
- Eclipse复制当前行问题(Intel屏幕旋转冲突)
- 创建表后查询报~未选定行~的错误
- 让 C#智能注释时允许换行
- 报名 | 智能制造:困惑中前行讲座
- 报名 | 智能制造:困惑中前行讲座
- WPF中给datagrid控件中dataTable添加新行,并选中设为当前行(源码加注释)
- 复制控制+智能指针
- 智能客户端SmartClient (一)
- 自治智能体(一)
- 使用Spring的Quartz方式实现Java定时器功能
- oracle 数据库审计
- C++之一些事一些情--函数传参
- jquery mobile常用的data-role类型
- BZOJ 1257 [CQOI2007]余数之和sum 题解
- Emacs自定义配置(一):智能复制行,未选定时注释当前行,Copy后智能缩进
- linux内核学习——内核同步
- Linux学习总结 Part-III
- Page 49, 自立题十五
- Linux操作系统下的多线程编程详细解析----条件变量pthread_cond_t那些事儿
- Hibernate中对增删改查的小结
- 一步一步实现五子棋6
- jQuery mobile网格布局
- C语言编译器浅析