Chinaunix首页 | 论坛 | 博客
  • 博客访问: 519010
  • 博文数量: 174
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 1827
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-15 14:12
文章分类

全部博文(174)

文章存档

2018年(1)

2017年(1)

2013年(3)

2012年(9)

2010年(12)

2009年(5)

2008年(106)

2007年(37)

我的朋友

分类: LINUX

2008-01-14 00:07:28

;; 注释/反注释一行或是一个区域的代码
;; 如果没有选择一个区域(region), 则注释掉/反注释当前的行
(global-set-key (kbd "C-/") 'tiw-comment)

(defun tiw-comment ()
  "comment/uncomment a line;; "
  (interactive)
  (save-excursion
    (if (gnus-region-active-p)
        (tiw-comment-region)
      (tiw-comment-line))))


(defun tiw-comment-line ()
  "comment or uncomment a line according to
the first charachter"
  (save-excursion
    (beginning-of-line)
    (if (looking-at comment-start)
        (uncomment-region (line-beginning-position) (line-end-position) nil)
      (comment-region  (line-beginning-position) (line-end-position) nil))))

(defun tiw-comment-region ()
  "comment or uncomment a region according to
the first character"
  (interactive)
  (let ((b-p (region-beginning))
        (e-p (region-end)))
    (save-excursion
      (goto-char (region-beginning))
      (if (looking-at comment-start)
          (uncomment-region b-p e-p nil)
        (comment-region b-p e-p nil)))))

阅读(1278) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~