[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 262a7c9ea0: New minor mode elide-head-mode
From: |
Po Lu |
Subject: |
Re: master 262a7c9ea0: New minor mode elide-head-mode |
Date: |
Sun, 09 Jan 2022 18:22:37 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) |
Stefan Kangas <stefankangas@gmail.com> writes:
> (defun elide-head (&optional arg)
> "Hide header material in buffer according to `elide-head-headers-to-hide'.
> @@ -88,43 +151,17 @@ The header is made invisible with an overlay. With a
> prefix arg, show
> an elided material again.
>
> This is suitable as an entry on `find-file-hook' or appropriate mode hooks."
> + (declare (obsolete elide-head-mode "29.1"))
> (interactive "P")
> (if arg
> - (elide-head-show)
> - (save-excursion
> - (save-restriction
> - (let ((rest elide-head-headers-to-hide)
> - beg end)
> - (widen)
> - (goto-char (point-min))
> - (while rest
> - (save-excursion
> - (when (re-search-forward (caar rest) nil t)
> - (setq beg (point))
> - (when (re-search-forward (cdar rest) nil t)
> - (setq end (point-marker)
> - rest nil))))
> - (if rest (setq rest (cdr rest))))
> - (if (not (and beg end))
> - (if (called-interactively-p 'interactive)
> - (message "No header found"))
> - (goto-char beg)
> - (end-of-line)
> - (if (overlayp elide-head-overlay)
> - (move-overlay elide-head-overlay (point-marker) end)
> - (setq elide-head-overlay (make-overlay (point-marker) end)))
> - (overlay-put elide-head-overlay 'invisible t)
> - (overlay-put elide-head-overlay 'evaporate t)
> - (overlay-put elide-head-overlay 'after-string "...")))))))
> + (elide-head--show)
> + (elide-head--hide)))
>
> (defun elide-head-show ()
> "Show a header in the current buffer elided by \\[elide-head]."
> + (declare (obsolete elide-head-mode "29.1"))
> (interactive)
> - (if (and (overlayp elide-head-overlay)
> - (overlay-buffer elide-head-overlay))
> - (delete-overlay elide-head-overlay)
> - (if (called-interactively-p 'interactive)
> - (message "No header hidden"))))
> + (elide-head--show))
Hmm... couldn't those two obsolete commands be made wrappers around
`elide-head-mode'?
For example:
(defun elide-head-show ()
"Show a header in the current buffer elided by \\[elide-head]."
(interactive)
(elide-head-mode 0))
And if those commands are made such simple wrappers, they could be
un-obsoleted as well, since it would be useful to explictly disable or
enable elide-head-mode inside `find-file-hook' and other similar places.
Thanks.
- Re: master 262a7c9ea0: New minor mode elide-head-mode,
Po Lu <=