[Top][All Lists]

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

[elpa] externals/excorporate e788f73 38/93: Advise icalendar--add-diary-

From: Stefan Monnier
Subject: [elpa] externals/excorporate e788f73 38/93: Advise icalendar--add-diary-entry conditionally
Date: Sun, 29 Nov 2020 15:43:04 -0500 (EST)

branch: externals/excorporate
commit e788f7394be2d12e24a2409a2d97629dd06e8a68
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>

    Advise icalendar--add-diary-entry conditionally
    * packages/excorporate/excorporate-diary.el: Add
    icalendar--add-diary-entry workaround advice conditional on real
    fix not being present.
    (excorporate-diary-enable): Call fixed diary-make-entry on Emacs
    versions >= 27.1.  (Bug#35645)
 excorporate-diary.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/excorporate-diary.el b/excorporate-diary.el
index a418f71..caaae20 100644
--- a/excorporate-diary.el
+++ b/excorporate-diary.el
@@ -33,7 +33,9 @@
 (require 'excorporate)
 (require 'nadvice)
-;; FIXME: Add something like this to diary-lib.el.
+;; For Emacs versions less than 27.1, which do not have the fix for
+;; Bug#35645, work around the issue where `icalendar-import-buffer'
+;; pops up the diary file buffer.
 (defun exco-diary-diary-make-entry (string &optional nonmarking file)
   "Insert a diary entry STRING which may be NONMARKING in FILE.
 If omitted, NONMARKING defaults to nil and FILE defaults to
@@ -55,8 +57,6 @@ If omitted, NONMARKING defaults to nil and FILE defaults to
      (if nonmarking diary-nonmarking-symbol "")
-;; FIXME: Have icalendar--add-diary-entry use the new diary-lib
-;; function instead of diary-make-entry.
 (defun exco-diary-icalendar--add-diary-entry-around (original &rest arguments)
   "Prevent whitespace workaround from selecting diary buffer.
 Also prevent `diary-make-entry' from putting the diary file
@@ -68,8 +68,10 @@ where (other-buffer (current-buffer)) will return it."
            ((symbol-function #'diary-make-entry)
             (symbol-function #'exco-diary-diary-make-entry)))
     (apply original arguments)))
-(advice-add #'icalendar--add-diary-entry :around
-           #'exco-diary-icalendar--add-diary-entry-around)
+(unless (string-match "omit-trailing-space" (documentation 'diary-make-entry))
+  (advice-add #'icalendar--add-diary-entry :around
+             #'exco-diary-icalendar--add-diary-entry-around))
 (defvar excorporate-diary-today-file
@@ -216,8 +218,11 @@ ARGUMENTS are the arguments to `diary-view-entries'."
        (goto-char (point-min))
        (when (not (re-search-forward
                    (concat "^ *" diary-include-string " *\"" file "\"") nil t))
-         (exco-diary-diary-make-entry
-          (concat diary-include-string " \"" file "\""))
+         (let ((include-string (concat diary-include-string " \"" file "\"")))
+           (if (string-match "omit-trailing-space"
+                             (documentation 'diary-make-entry))
+               (diary-make-entry include-string nil nil t t)
+             (exco-diary-diary-make-entry include-string)))
   (advice-add #'diary :around #'exco-diary-diary-around)
   (advice-add #'diary-view-entries :override

reply via email to

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