* [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1
@ 2023-01-24 2:52 Aaron L. Zeng
2023-01-24 9:23 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Aaron L. Zeng @ 2023-01-24 2:52 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Aaron L. Zeng
* org-compat.el (org-string-pad): Add compatibility function
`org-string-pad' for `string-pad', introduced in Emacs 28.1.
* org-agenda.el (org-fix-agenda-info): Use `org-string-pad' rather
than `string-pad'.
Since this is more-or-less just copying string-pad's definition from
subr-x.el, I think this qualifies for TINYCHANGE.
TINYCHANGE
---
lisp/org-agenda.el | 4 ++--
lisp/org-compat.el | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 2d194ad34..4f0522086 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3474,13 +3474,13 @@ This ensures the export commands can easily use it."
(when (setq tmp (plist-get props 'date))
(when (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
(let ((calendar-date-display-form
- '(year "-" (string-pad month 2 ?0 'left) "-" (string-pad day 2 ?0 'left))))
+ '(year "-" (org-string-pad month 2 ?0 'left) "-" (org-string-pad day 2 ?0 'left))))
(setq tmp (calendar-date-string tmp)))
(setq props (plist-put props 'date tmp)))
(when (setq tmp (plist-get props 'day))
(when (integerp tmp) (setq tmp (calendar-gregorian-from-absolute tmp)))
(let ((calendar-date-display-form
- '(year "-" (string-pad month 2 ?0 'left) "-" (string-pad day 2 ?0 'left))))
+ '(year "-" (org-string-pad month 2 ?0 'left) "-" (org-string-pad day 2 ?0 'left))))
(setq tmp (calendar-date-string tmp)))
(setq props (plist-put props 'day tmp))
(setq props (plist-put props 'agenda-day tmp)))
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 6c5085255..eb20d5baf 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -173,6 +173,27 @@ removed."
(string-trim (replace-regexp-in-string blank " " string t t)
blank blank))))
+(if (fboundp 'string-pad)
+ (defalias 'org-string-pad #'string-pad)
+ ;; From Emacs subr-x.el.
+ (defun org-string-pad (string length &optional padding start)
+ "Pad STRING to LENGTH using PADDING.
+If PADDING is nil, the space character is used. If not nil, it
+should be a character.
+
+If STRING is longer than the absolute value of LENGTH, no padding
+is done.
+
+If START is nil (or not present), the padding is done to the end
+of the string, and if non-nil, padding is done to the start of
+the string."
+ (unless (natnump length)
+ (signal 'wrong-type-argument (list 'natnump length)))
+ (let ((pad-length (- length (length string))))
+ (cond ((<= pad-length 0) string)
+ (start (concat (make-string pad-length (or padding ?\s)) string))
+ (t (concat string (make-string pad-length (or padding ?\s))))))))
+
(if (fboundp 'format-prompt)
(defalias 'org-format-prompt #'format-prompt)
;; From Emacs minibuffer.el, inlining
--
2.38.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1
2023-01-24 2:52 [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1 Aaron L. Zeng
@ 2023-01-24 9:23 ` Ihor Radchenko
2023-01-24 16:30 ` Aaron Zeng
0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-01-24 9:23 UTC (permalink / raw)
To: Aaron L. Zeng; +Cc: emacs-orgmode
"Aaron L. Zeng" <me@bcc32.com> writes:
> * org-compat.el (org-string-pad): Add compatibility function
> `org-string-pad' for `string-pad', introduced in Emacs 28.1.
>
> * org-agenda.el (org-fix-agenda-info): Use `org-string-pad' rather
> than `string-pad'.
>
> Since this is more-or-less just copying string-pad's definition from
> subr-x.el, I think this qualifies for TINYCHANGE.
Thanks!
This issue has not been caught by byte-compilation.
I applied an alternative fix not using `string-pad' at all.
Canceled.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5bbb97f3df9788646b8d48d60e8b8ea06566e05f
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1
2023-01-24 9:23 ` Ihor Radchenko
@ 2023-01-24 16:30 ` Aaron Zeng
2023-01-24 17:47 ` Aaron Zeng
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Zeng @ 2023-01-24 16:30 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]
Thanks for the quick response, Ihor!
On Tue, Jan 24, 2023 at 4:23 AM Ihor Radchenko <yantar92@posteo.net> wrote:
> "Aaron L. Zeng" <me@bcc32.com> writes:
>
> > * org-compat.el (org-string-pad): Add compatibility function
> > `org-string-pad' for `string-pad', introduced in Emacs 28.1.
> >
> > * org-agenda.el (org-fix-agenda-info): Use `org-string-pad' rather
> > than `string-pad'.
> >
> > Since this is more-or-less just copying string-pad's definition from
> > subr-x.el, I think this qualifies for TINYCHANGE.
>
> Thanks!
> This issue has not been caught by byte-compilation.
>
> I applied an alternative fix not using `string-pad' at all.
> Canceled.
>
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5bbb97f3df9788646b8d48d60e8b8ea06566e05f
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>
[-- Attachment #2: Type: text/html, Size: 1876 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1
2023-01-24 16:30 ` Aaron Zeng
@ 2023-01-24 17:47 ` Aaron Zeng
2023-01-24 18:21 ` Ihor Radchenko
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Zeng @ 2023-01-24 17:47 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1263 bytes --]
Hi Ihor, I just noticed that this patch only fixes one of the lines calling
`string-pad'. There is another callsite below which needs to be removed.
On Tue, Jan 24, 2023 at 11:30 AM Aaron Zeng <me@bcc32.com> wrote:
> Thanks for the quick response, Ihor!
>
> On Tue, Jan 24, 2023 at 4:23 AM Ihor Radchenko <yantar92@posteo.net>
> wrote:
>
>> "Aaron L. Zeng" <me@bcc32.com> writes:
>>
>> > * org-compat.el (org-string-pad): Add compatibility function
>> > `org-string-pad' for `string-pad', introduced in Emacs 28.1.
>> >
>> > * org-agenda.el (org-fix-agenda-info): Use `org-string-pad' rather
>> > than `string-pad'.
>> >
>> > Since this is more-or-less just copying string-pad's definition from
>> > subr-x.el, I think this qualifies for TINYCHANGE.
>>
>> Thanks!
>> This issue has not been caught by byte-compilation.
>>
>> I applied an alternative fix not using `string-pad' at all.
>> Canceled.
>>
>>
>> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5bbb97f3df9788646b8d48d60e8b8ea06566e05f
>>
>> --
>> Ihor Radchenko // yantar92,
>> Org mode contributor,
>> Learn more about Org mode at <https://orgmode.org/>.
>> Support Org development at <https://liberapay.com/org-mode>,
>> or support my work at <https://liberapay.com/yantar92>
>>
>
[-- Attachment #2: Type: text/html, Size: 2398 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1
2023-01-24 17:47 ` Aaron Zeng
@ 2023-01-24 18:21 ` Ihor Radchenko
2023-01-24 18:35 ` Aaron Zeng
0 siblings, 1 reply; 6+ messages in thread
From: Ihor Radchenko @ 2023-01-24 18:21 UTC (permalink / raw)
To: Aaron Zeng; +Cc: emacs-orgmode
Aaron Zeng <me@bcc32.com> writes:
> Hi Ihor, I just noticed that this patch only fixes one of the lines calling
> `string-pad'. There is another callsite below which needs to be removed.
Oops. Now, should be good.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=20ee7b85ebc0e3e08805b1e9e3e824f50347340e
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1
2023-01-24 18:21 ` Ihor Radchenko
@ 2023-01-24 18:35 ` Aaron Zeng
0 siblings, 0 replies; 6+ messages in thread
From: Aaron Zeng @ 2023-01-24 18:35 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 670 bytes --]
Much obliged :)
On Tue, Jan 24, 2023 at 1:20 PM Ihor Radchenko <yantar92@posteo.net> wrote:
> Aaron Zeng <me@bcc32.com> writes:
>
> > Hi Ihor, I just noticed that this patch only fixes one of the lines
> calling
> > `string-pad'. There is another callsite below which needs to be removed.
>
> Oops. Now, should be good.
>
> https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=20ee7b85ebc0e3e08805b1e9e3e824f50347340e
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>
[-- Attachment #2: Type: text/html, Size: 1454 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-01-24 18:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-24 2:52 [PATCH] lisp/org-agenda.el: Fix void-function string-pad in Emacs <28.1 Aaron L. Zeng
2023-01-24 9:23 ` Ihor Radchenko
2023-01-24 16:30 ` Aaron Zeng
2023-01-24 17:47 ` Aaron Zeng
2023-01-24 18:21 ` Ihor Radchenko
2023-01-24 18:35 ` Aaron Zeng
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.