unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
To: 45808@debbugs.gnu.org
Subject: bug#45808: 28.0.50; [PATCH] Add option remember-diary-regexp
Date: Tue, 12 Jan 2021 00:26:25 -0300	[thread overview]
Message-ID: <CH2PR01MB5879B3ABE5AD3ECA76B6C1A78BAA0@CH2PR01MB5879.prod.exchangelabs.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 131 bytes --]

The regexp to extract diary entries on remember.el is hardcoded.
Here is a patch to add a new option to configure a custom regexp.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-option-remember-diary-regexp.patch --]
[-- Type: text/x-diff, Size: 1508 bytes --]

From aab8cce70c80e824e77fb6b8e13eaa683c2714f0 Mon Sep 17 00:00:00 2001
From: Gabriel do Nascimento Ribeiro <gabriel.nascimento@nubank.com.br>
Date: Tue, 12 Jan 2021 00:19:28 -0300
Subject: [PATCH] Add option remember-diary-regexp

---
 lisp/textmodes/remember.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 98d3a3856e..ed5144443b 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -159,7 +159,8 @@
 ;;   ;; This should be before other entries that may return t
 ;;   (add-to-list 'remember-handler-functions 'remember-diary-extract-entries)
 ;;
-;; This module recognizes entries of the form
+;; This module recognizes entries of the form (defined by
+;; remember-diary-regexp)
 ;;
 ;;   DIARY: ....
 ;;
@@ -532,13 +533,18 @@ remember-diary-convert-entry
 
 (autoload 'diary-make-entry "diary-lib")
 
+(defcustom remember-diary-regexp "^DIARY:\\s-*\\(.+\\)"
+  "Regexp to extract diary entries."
+  :type 'regexp
+  :version "28.1")
+
 ;;;###autoload
 (defun remember-diary-extract-entries ()
   "Extract diary entries from the region."
   (save-excursion
     (goto-char (point-min))
     (let (list)
-      (while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t)
+      (while (re-search-forward remember-diary-regexp nil t)
         (push (remember-diary-convert-entry (match-string 1)) list))
       (when list
         (diary-make-entry (mapconcat 'identity list "\n")
-- 
2.27.0


             reply	other threads:[~2021-01-12  3:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12  3:26 Gabriel do Nascimento Ribeiro [this message]
2021-01-12 15:15 ` bug#45808: 28.0.50; [PATCH] Add option remember-diary-regexp Eli Zaretskii
2021-01-12 15:53   ` Gabriel do Nascimento Ribeiro
2021-01-20 16:46     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CH2PR01MB5879B3ABE5AD3ECA76B6C1A78BAA0@CH2PR01MB5879.prod.exchangelabs.com \
    --to=gabriel376@hotmail.com \
    --cc=45808@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).