Open selected `outline-mode' files in `read-only-mode'

This commit is contained in:
Gerard Vermeulen 2024-05-09 09:36:17 +02:00
parent d3a3a2ceb2
commit d6a9320fb9
1 changed files with 21 additions and 0 deletions

View File

@ -2036,6 +2036,27 @@ file.
| *pdf-view-fit-width-to-window* | {{{kbd(W)}}} |
|---------------------------------+----------------|
** Reading outline files
:PROPERTIES:
:CUSTOM_ID: sec:reading-outline-files
:END:
#+caption[Enable ~read-only-mode~ for some files in ~outline-mode~]:
#+caption: Enable ~read-only-mode~ for some files in ~outline-mode~.
#+name: lst:maybe-read-only-in-outline-mode
#+begin_src emacs-lisp -n :results silent
(defun maybe-read-only-in-outline-mode ()
;; GAV: Should be a toplevel function to call `message' here.
(let ((fnsd (buffer-file-name)))
;; GAV: `fnsd' is nil during Org export to LaTeX.
(when fnsd
(setq fnsd (file-name-nondirectory fnsd))
(when (member fnsd '("NEWS" "ORG-NEWS" "PROBLEMS"))
(message "Visit `%s' in `read-only-mode'" fnsd)
(read-only-mode +1)))))
(add-hook 'outline-mode-hook #'maybe-read-only-in-outline-mode)
#+end_src
* Writing
:PROPERTIES:
:CUSTOM_ID: sec:writing