emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: org-capture: %L causes arg out of range error for empty string annotation [9.4 (release_9.4-31-g8c44f2 @ /home/n/.emacs.d/straight/build/org/)]
@ 2020-09-25  7:34 No Wayman
  2020-09-25  7:48 ` No Wayman
  0 siblings, 1 reply; 3+ messages in thread
From: No Wayman @ 2020-09-25  7:34 UTC (permalink / raw)
  To: emacs-orgmode


d06aa486d6c3163b6ef6e9ab665117bd93dff34a introduces the following 
in
`org-capture-fill-template':

> (v-L (if (or v-a (string-match l-re v-a))
>                 (replace-match "\\1" nil nil v-a)
>               v-a))

If `v-a' is an empty string, the call to `replace-match' throws an 
Args out of range error. Similar assignments in that are of the 
code use an `and' comparison to guard against this, so perhaps it 
should be:


> (v-L (if (and v-a (string-match l-re v-a))
>                 (replace-match "\\1" nil nil v-a)
>               v-a))


Emacs  : GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.23, cairo version 1.17.3)
 of 2020-09-19
Package: Org mode version 9.4 (release_9.4-31-g8c44f2 @ 
/home/n/.emacs.d/straight/build/org/)


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

* Re: Bug: org-capture: %L causes arg out of range error for empty string annotation [9.4 (release_9.4-31-g8c44f2 @ /home/n/.emacs.d/straight/build/org/)]
  2020-09-25  7:34 Bug: org-capture: %L causes arg out of range error for empty string annotation [9.4 (release_9.4-31-g8c44f2 @ /home/n/.emacs.d/straight/build/org/)] No Wayman
@ 2020-09-25  7:48 ` No Wayman
  2020-09-26  2:37   ` Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: No Wayman @ 2020-09-25  7:48 UTC (permalink / raw)
  To: emacs-orgmode

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


No Wayman <iarchivedmywholelife@gmail.com> writes:

> If `v-a' is an empty string, the call to `replace-match' throws 
> an
> Args out of range error. Similar assignments in that area of the
> code use an `and' comparison to guard against this, so perhaps 
> it
> should be:
>
>
>> (v-L (if (and v-a (string-match l-re v-a))
>>                 (replace-match "\\1" nil nil v-a)
>>               v-a))

See attached patch


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-capture-Fix-bare-link-Args-out-of-range.patch --]
[-- Type: text/x-patch, Size: 894 bytes --]

From be476c236e40dd0ba87be9d466dd5cd00a6960b7 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholelife@gmail.com>
Date: Fri, 25 Sep 2020 03:42:57 -0400
Subject: [PATCH] capture: Fix bare link "Args out of range"

* lisp/org-capture.el (org-capture-fill-template): guard against empty
annotation string
---
 lisp/org-capture.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index a6e95f24e..67c58ffdd 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1595,7 +1595,7 @@ The template may still contain \"%?\" for cursor positioning."
 	 (v-l (if (and v-a (string-match l-re v-a))
 		  (replace-match "[[\\1]]" nil nil v-a)
 		v-a))
-	 (v-L (if (or v-a (string-match l-re v-a))
+	 (v-L (if (and v-a (string-match l-re v-a))
 		  (replace-match "\\1" nil nil v-a)
 		v-a))
 	 (v-n user-full-name)
-- 
2.28.0


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

* Re: Bug: org-capture: %L causes arg out of range error for empty string annotation [9.4 (release_9.4-31-g8c44f2 @ /home/n/.emacs.d/straight/build/org/)]
  2020-09-25  7:48 ` No Wayman
@ 2020-09-26  2:37   ` Kyle Meyer
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle Meyer @ 2020-09-26  2:37 UTC (permalink / raw)
  To: No Wayman; +Cc: emacs-orgmode

No Wayman writes:

> No Wayman <iarchivedmywholelife@gmail.com> writes:
>
>> If `v-a' is an empty string, the call to `replace-match' throws 
>> an
>> Args out of range error. Similar assignments in that area of the
>> code use an `and' comparison to guard against this, so perhaps 
>> it
>> should be:
>>
>>
>>> (v-L (if (and v-a (string-match l-re v-a))
>>>                 (replace-match "\\1" nil nil v-a)
>>>               v-a))
>
> See attached patch

Thank you.  Applied (1d66a58a2).


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

end of thread, other threads:[~2020-09-26  2:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25  7:34 Bug: org-capture: %L causes arg out of range error for empty string annotation [9.4 (release_9.4-31-g8c44f2 @ /home/n/.emacs.d/straight/build/org/)] No Wayman
2020-09-25  7:48 ` No Wayman
2020-09-26  2:37   ` Kyle Meyer

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).