emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] counter macro doesn't increment when additional macro is on same lin


From: Matt Price
Subject: [O] counter macro doesn't increment when additional macro is on same line
Date: Sat, 26 Aug 2017 17:09:16 -0400


the {{{n}}} macro seems to reset to "1" if it is located on the same line as another macro that I've defined.  I'm not sure if it's error with my macro or some kind or race condition-ish problem in macro expansion.  Here's a minimal example:

--------
#+MACRO: ts (eval (get-ts+7))

#+BEGIN_SRC emacs-lisp
  (defun mwp-add-week-to-next-ts ()
    (interactive )
    (save-excursion
      (re-search-forward org-ts-regexp)

      (let ((base (match-string 0)))
        (message base)
        (message (format-time-string "<%Y-%m-%d %a>"
                                     (time-add (date-to-time base) (days-to-time (1+ 7)))))

        (replace-match (format-time-string "<%Y-%m-%d %a>"
                                           (time-add (date-to-time base) (seconds-to-time (1+(* 7 60 60 24))))) nil nil nil nil))))
#+END_SRC

(week {{{n(w)}}})

(week {{{n(w)}}})

(week {{{n(w)}}})


** <2017-09-12 Tue> (Week {{{n(w)}}}) Hacking History in the Himalaya

** {{{ts}}} (Week {{{n(w)}}}) Language of the Web

-----------------

And here's the ASCII export:

------
Matt Price


,----
| (defun mwp-add-week-to-next-ts ()
|   (interactive )
|   (save-excursion
|     (re-search-forward org-ts-regexp)
|
|     (let ((base (match-string 0)))
|       (message base)
|       (message (format-time-string "<%Y-%m-%d %a>"
|                                    (time-add (date-to-time base) (days-to-time (1+ 7)))))
|
|       (replace-match (format-time-string "<%Y-%m-%d %a>"
|                                          (time-add (date-to-time base) (seconds-to-time (1+(* 7 60 60 24))))) nil nil nil nil))))
`----

1

2

3


<2017-09-12 Tue>  (Week 4) Hacking History in the Himalaya
==========================================================


<2017-09-19 Tue>  (Week 1) Language of the Web
==============================================
-----------------

Any thoughts? thank you!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]