diff options
-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))))) |