Skip to content

Commit

Permalink
no summary available
Browse files Browse the repository at this point in the history
  • Loading branch information
DrewAdams authored and kensanata committed May 10, 2012
1 parent 06f0e41 commit e52647b
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions hide-comnt.el
Expand Up @@ -7,9 +7,9 @@
;; Copyright (C) 2011-2012, Drew Adams, all rights reserved. ;; Copyright (C) 2011-2012, Drew Adams, all rights reserved.
;; Created: Wed May 11 07:11:30 2011 (-0700) ;; Created: Wed May 11 07:11:30 2011 (-0700)
;; Version: ;; Version:
;; Last-Updated: Sun Jan 1 16:00:08 2012 (-0800) ;; Last-Updated: Thu May 10 06:56:04 2012 (-0700)
;; By: dradams ;; By: dradams
;; Update #: 19 ;; Update #: 39
;; URL: http://www.emacswiki.org/cgi-bin/wiki/hide-comnt.el ;; URL: http://www.emacswiki.org/cgi-bin/wiki/hide-comnt.el
;; Keywords: comment, hide, show ;; Keywords: comment, hide, show
;; Compatibility: GNU Emacs: 21.x, 22.x, 23.x ;; Compatibility: GNU Emacs: 21.x, 22.x, 23.x
Expand All @@ -31,7 +31,7 @@
;; ;;
;; Commands defined here: ;; Commands defined here:
;; ;;
;; `hide/show-comments', ;; `hide/show-comments', `hide/show-comments-toggle'.
;; ;;
;; User options defined here: ;; User options defined here:
;; ;;
Expand All @@ -46,6 +46,8 @@
;; ;;
;;; Change Log: ;;; Change Log:
;; ;;
;; 2012/05/10 dadams
;; Added: hide/show-comments-toggle. Thx to Denny Zhang for the suggestion.
;; 2011/11/23 dadams ;; 2011/11/23 dadams
;; hide/show-comments: Bug fix - ensure CEND is not past eob. ;; hide/show-comments: Bug fix - ensure CEND is not past eob.
;; 2011/05/11 dadams ;; 2011/05/11 dadams
Expand Down Expand Up @@ -143,6 +145,24 @@ because it needs `comment-search-forward'."
(put-text-property cbeg cend 'invisible nil))))) (put-text-property cbeg cend 'invisible nil)))))
(set-buffer-modified-p bufmodp))))) (set-buffer-modified-p bufmodp)))))


(defun hide/show-comments-toggle (&optional start end)
"Toggle hiding/showing of comments in the active region or whole buffer.
If the region is active then toggle in the region. Otherwise, in the
whole buffer.
Interactively, START and END default to the region limits, if active.
Otherwise, including non-interactively, they default to `point-min'
and `point-max'.
See `hide/show-comments' for more information."
(interactive (if (or (not mark-active) (null (mark)) (= (point) (mark)))
(list (point-min) (point-max))
(if (< (point) (mark)) (list (point) (mark)) (list (mark) (point)))))
(if (save-excursion (goto-char start) (and (comment-search-forward end 'NOERROR)
(get-text-property (point) 'invisible)))
(hide/show-comments 'show start end)
(hide/show-comments 'hide start end)))

;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;


(provide 'hide-comnt) (provide 'hide-comnt)
Expand Down

0 comments on commit e52647b

Please sign in to comment.