Skip to content

Commit

Permalink
Add option remember-text-format-function
Browse files Browse the repository at this point in the history
* lisp/textmodes/remember.el (remember-text-format-function): New
variable (bug#45809).
(remember-append-to-file): Use it.
  • Loading branch information
gabriel376 authored and larsmagne committed Jan 20, 2021
1 parent 72d4522 commit edf6350
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions etc/NEWS
Expand Up @@ -1560,6 +1560,9 @@ that makes it a valid button.
---
*** New user option 'remember-diary-regexp'.

---
*** New user option 'remember-text-format-function'.

*** New function 'buffer-line-statistics'.
This function returns some statistics about the line lengths in a buffer.

Expand Down
17 changes: 14 additions & 3 deletions lisp/textmodes/remember.el
Expand Up @@ -411,13 +411,24 @@ The default emulates `current-time-string' for backward compatibility."
:group 'remember
: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 ()
"Remember, with description DESC, the given TEXT."
(let* ((text (buffer-string))
(desc (remember-buffer-desc))
(remember-text (concat "\n" remember-leader-text
(format-time-string remember-time-format)
" (" desc ")\n\n" text
(remember-text (concat "\n"
(if remember-text-format-function
(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))
(if (bolp) nil "\n"))))
(buf (find-buffer-visiting remember-data-file)))
Expand Down

0 comments on commit edf6350

Please sign in to comment.