unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / Atom feed
* bug#45808: 28.0.50; [PATCH] Add option remember-diary-regexp
@ 2021-01-12  3:26 Gabriel do Nascimento Ribeiro
  2021-01-12 15:15 ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Gabriel do Nascimento Ribeiro @ 2021-01-12  3:26 UTC (permalink / raw)
  To: 45808

[-- 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#45808: 28.0.50; [PATCH] Add option remember-diary-regexp
  2021-01-12  3:26 bug#45808: 28.0.50; [PATCH] Add option remember-diary-regexp Gabriel do Nascimento Ribeiro
@ 2021-01-12 15:15 ` Eli Zaretskii
  2021-01-12 15:53   ` Gabriel do Nascimento Ribeiro
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2021-01-12 15:15 UTC (permalink / raw)
  To: Gabriel do Nascimento Ribeiro; +Cc: 45808

> From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
> Date: Tue, 12 Jan 2021 00:26:25 -0300
> 
> 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.

Thanks, but can you please describe the situation where this regexp
will need to be modified?





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#45808: 28.0.50; [PATCH] Add option remember-diary-regexp
  2021-01-12 15:15 ` Eli Zaretskii
@ 2021-01-12 15:53   ` Gabriel do Nascimento Ribeiro
  0 siblings, 0 replies; 3+ messages in thread
From: Gabriel do Nascimento Ribeiro @ 2021-01-12 15:53 UTC (permalink / raw)
  To: 45808

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

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
>> Date: Tue, 12 Jan 2021 00:26:25 -0300
>> 
>> 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.
>
> Thanks, but can you please describe the situation where this regexp
> will need to be modified?

There are multiple cases, for example, if the user wants to
automatically extract diary entries of lines that starts with a date
pattern (e.g.: dd/mm/yyyy). This new option does not target a specific
user case but rather opens a range of possibilities by not relying on a
hardcoded (and not documented) behavior.

By the way, here is a patch with updated docstring.

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

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

---
 lisp/textmodes/remember.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 98d3a3856e..5558bd7ec5 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."
+  "Extract diary entries from the region based on `remember-diary-regexp'."
   (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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-12 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12  3:26 bug#45808: 28.0.50; [PATCH] Add option remember-diary-regexp Gabriel do Nascimento Ribeiro
2021-01-12 15:15 ` Eli Zaretskii
2021-01-12 15:53   ` Gabriel do Nascimento Ribeiro

unofficial mirror of bug-gnu-emacs@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/emacs-bugs/0 emacs-bugs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 emacs-bugs emacs-bugs/ https://yhetil.org/emacs-bugs \
		bug-gnu-emacs@gnu.org
	public-inbox-index emacs-bugs

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.bugs
	nntp://news.gmane.io/gmane.emacs.bugs


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git