1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-21 21:20:44 -08:00

Add option remember-text-format-function

* lisp/textmodes/remember.el (remember-text-format-function): New
variable (bug#45809).
(remember-append-to-file): Use it.
This commit is contained in:
Gabriel do Nascimento Ribeiro 2021-01-20 17:53:04 +01:00 committed by Lars Ingebrigtsen
parent 72d4522b05
commit edf6350e7f
2 changed files with 17 additions and 3 deletions

View file

@ -1560,6 +1560,9 @@ that makes it a valid button.
--- ---
*** New user option 'remember-diary-regexp'. *** New user option 'remember-diary-regexp'.
---
*** New user option 'remember-text-format-function'.
*** New function 'buffer-line-statistics'. *** New function 'buffer-line-statistics'.
This function returns some statistics about the line lengths in a buffer. This function returns some statistics about the line lengths in a buffer.

View file

@ -411,13 +411,24 @@ The default emulates `current-time-string' for backward compatibility."
:group 'remember :group 'remember
:version "27.1") :version "27.1")
(defcustom remember-text-format-function nil
"The function to format the remembered text.
The function receives the remembered text as argument and should
return the text to be remembered."
:type 'function
:group 'remember
:version "28.1")
(defun remember-append-to-file () (defun remember-append-to-file ()
"Remember, with description DESC, the given TEXT." "Remember, with description DESC, the given TEXT."
(let* ((text (buffer-string)) (let* ((text (buffer-string))
(desc (remember-buffer-desc)) (desc (remember-buffer-desc))
(remember-text (concat "\n" remember-leader-text (remember-text (concat "\n"
(format-time-string remember-time-format) (if remember-text-format-function
" (" desc ")\n\n" text (funcall remember-text-format-function text)
(concat remember-leader-text
(format-time-string remember-time-format)
" (" desc ")\n\n" text))
(save-excursion (goto-char (point-max)) (save-excursion (goto-char (point-max))
(if (bolp) nil "\n")))) (if (bolp) nil "\n"))))
(buf (find-buffer-visiting remember-data-file))) (buf (find-buffer-visiting remember-data-file)))