Commit 890a0826 authored by Thomas Fitzsimmons's avatar Thomas Fitzsimmons

Make icalendar-import-buffer not show diary file buffer

* lisp/calendar/diary-lib.el (diary-make-entry): Add
omit-trailing-space parameter.  Add do-not-show parameter to
allow not showing diary file buffer.
* lisp/calendar/icalendar.el (icalendar--add-diary-entry): Remove
workaround to omit trailing space in diary entry.  Have
diary-make-entry not display the diary file buffer.  (Bug#35645)
parent 58cde923
Pipeline #1928 failed with stage
in 3 seconds
...@@ -2062,27 +2062,34 @@ calendar." ...@@ -2062,27 +2062,34 @@ calendar."
;;; Diary insertion functions. ;;; Diary insertion functions.
;;;###cal-autoload ;;;###cal-autoload
(defun diary-make-entry (string &optional nonmarking file) (defun diary-make-entry (string &optional nonmarking file omit-trailing-space
do-not-show)
"Insert a diary entry STRING which may be NONMARKING in FILE. "Insert a diary entry STRING which may be NONMARKING in FILE.
If omitted, NONMARKING defaults to nil and FILE defaults to If omitted, NONMARKING defaults to nil and FILE defaults to
`diary-file'." `diary-file'. If OMIT-TRAILING-SPACE is non-nil, then do not add
(let ((pop-up-frames (or pop-up-frames (window-dedicated-p)))) a trailing space to the entry. If DO-NOT-SHOW is non-nil, do not
(find-file-other-window (or file diary-file))) show the diary buffer."
(when (eq major-mode (default-value 'major-mode)) (diary-mode)) (with-current-buffer
(widen) (let ((diary-file-name (or file diary-file)))
(diary-unhide-everything) (if do-not-show
(goto-char (point-max)) (find-file-noselect diary-file-name)
(when (let ((case-fold-search t)) (let ((pop-up-frames (or pop-up-frames (window-dedicated-p))))
(search-backward "Local Variables:" (find-file-other-window diary-file-name))))
(max (- (point-max) 3000) (point-min)) (when (eq major-mode (default-value 'major-mode)) (diary-mode))
t)) (widen)
(beginning-of-line) (diary-unhide-everything)
(insert "\n") (goto-char (point-max))
(forward-line -1)) (when (let ((case-fold-search t))
(insert (search-backward "Local Variables:"
(if (bolp) "" "\n") (max (- (point-max) 3000) (point-min))
(if nonmarking diary-nonmarking-symbol "") t))
string " ")) (beginning-of-line)
(insert "\n")
(forward-line -1))
(insert
(if (bolp) "" "\n")
(if nonmarking diary-nonmarking-symbol "")
string (if omit-trailing-space "" " "))))
;;;###cal-autoload ;;;###cal-autoload
(defun diary-insert-entry (arg &optional event) (defun diary-insert-entry (arg &optional event)
......
...@@ -2502,20 +2502,10 @@ the entry." ...@@ -2502,20 +2502,10 @@ the entry."
(when summary (when summary
(setq non-marking (setq non-marking
(y-or-n-p (format "Make appointment non-marking? ")))) (y-or-n-p (format "Make appointment non-marking? "))))
(save-window-excursion (unless diary-filename
(unless diary-filename (setq diary-filename
(setq diary-filename (read-file-name "Add appointment to this diary file: ")))
(read-file-name "Add appointment to this diary file: "))) (diary-make-entry string non-marking diary-filename t t))
;; Note: diary-make-entry will add a trailing blank char.... :(
(funcall (if (fboundp 'diary-make-entry)
'diary-make-entry
'make-diary-entry)
string non-marking diary-filename)))
;; Würgaround to remove the trailing blank char
(with-current-buffer (find-file diary-filename)
(goto-char (point-max))
(if (= (char-before) ? )
(delete-char -1)))
;; return diary-filename in case it has been changed interactively ;; return diary-filename in case it has been changed interactively
diary-filename) diary-filename)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment