diff options
author | Adrian Kummerlaender | 2020-06-08 23:38:25 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2020-06-08 23:38:25 +0200 |
commit | f19cceb14aba12b007e7c38d27b7231b7e36b4e4 (patch) | |
tree | 55651d074eeaba3f55de89616af4f3baa18fca6c | |
parent | 57d7d7b9008ac8526d68ab1879fe45cc27872d9a (diff) | |
download | nixos_home-f19cceb14aba12b007e7c38d27b7231b7e36b4e4.tar nixos_home-f19cceb14aba12b007e7c38d27b7231b7e36b4e4.tar.gz nixos_home-f19cceb14aba12b007e7c38d27b7231b7e36b4e4.tar.bz2 nixos_home-f19cceb14aba12b007e7c38d27b7231b7e36b4e4.tar.lz nixos_home-f19cceb14aba12b007e7c38d27b7231b7e36b4e4.tar.xz nixos_home-f19cceb14aba12b007e7c38d27b7231b7e36b4e4.tar.zst nixos_home-f19cceb14aba12b007e7c38d27b7231b7e36b4e4.zip |
Use narrowing to hide C-style copyright comments in Emacs
-rw-r--r-- | gui/conf/init.el | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/gui/conf/init.el b/gui/conf/init.el index 280d768..7fe350a 100644 --- a/gui/conf/init.el +++ b/gui/conf/init.el @@ -207,15 +207,17 @@ (use-package ag :ensure t) -(defun hide-banner () +(defun copyright-message-p () + "Returns t when the current buffer starts with a Copyright note" (save-excursion - (let* ((start (progn (beginning-of-buffer) (point))) - (end (progn (forward-comment (buffer-size)) (point))) - (header-comment-hider (make-overlay start end))) - (overlay-put header-comment-hider 'invisible t)))) + (goto-char (point-min)) + (looking-at "\\s */\\*\\(:?\\s \\|\\*\\)*\\(This file\\|Copyright\\)\\b"))) -(defun unhide-banner () +(defun hide-copyright-note () + "Tries to narrow the current buffer so that the copyright comment is hidden" (interactive) - (delete-overlay 'header-comment-hider)) - -(add-hook 'c-mode-common-hook 'hide-banner) + (when (copyright-message-p) + (save-excursion + (let* ((start (progn (goto-char (point-min)) (forward-comment (buffer-size)) (point))) + (end (progn (end-of-buffer) (point)))) + (narrow-to-region start end))))) |