1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-11-21 06:55:35 +00:00

org-agenda-write: Remove redundant `set-buffer'

* lisp/org-agenda.el (org-agenda-write): Drop `set-buffer' call at the
end.  It does nothing since the rest of the code is wrapped in
`save-excursion' and the aim of the `set-buffer' is to switch to the
agenda buffer we just saved.  Ignore AGENDA-BUFNAME argument - it is
unused now.  Update the docstring, removing the mention of what
appears to be the now-ignored argument.
(org--batch-store-agenda-views): Update the caller.  Passing current
agenda buffer name is no longer necessary.  We set it before the call
anyway.

Reported-by: Sławomir Grochowski <slawomir.grochowski@gmail.com>
Link: https://orgmode.org/list/87ed7dwygq.fsf@gmail.com
This commit is contained in:
Ihor Radchenko 2024-07-28 20:49:25 +02:00
parent d3d84ff6b9
commit 433fbdbc63
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B

View File

@ -3577,8 +3577,7 @@ This ensures the export commands can easily use it."
(set-buffer bufname) (set-buffer bufname)
(while files (while files
(cl-progv vars vals (cl-progv vars vals
(org-agenda-write (expand-file-name (pop files) dir) (org-agenda-write (expand-file-name (pop files) dir) nil t))))
nil t bufname))))
(and (get-buffer bufname) (and (get-buffer bufname)
(kill-buffer bufname))))))) (kill-buffer bufname)))))))
@ -3596,7 +3595,7 @@ This ensures the export commands can easily use it."
(defvar org-mobile-creating-agendas) ; defined in org-mobile.el (defvar org-mobile-creating-agendas) ; defined in org-mobile.el
(defvar org-agenda-write-buffer-name "Agenda View") (defvar org-agenda-write-buffer-name "Agenda View")
(defun org-agenda-write (file &optional open nosettings agenda-bufname) (defun org-agenda-write (file &optional open nosettings _)
"Write the current buffer (an agenda view) as a file. "Write the current buffer (an agenda view) as a file.
Depending on the extension of the file name, plain text (.txt), Depending on the extension of the file name, plain text (.txt),
@ -3609,9 +3608,7 @@ With prefix argument OPEN, open the new file immediately. If
NOSETTINGS is given, do not scope the settings of NOSETTINGS is given, do not scope the settings of
`org-agenda-exporter-settings' into the export commands. This is `org-agenda-exporter-settings' into the export commands. This is
used when the settings have already been scoped and we do not used when the settings have already been scoped and we do not
wish to overrule other, higher priority settings. If wish to overrule other, higher priority settings."
AGENDA-BUFFER-NAME is provided, use this as the buffer name for
the agenda to write."
(interactive "FWrite agenda to file: \nP") (interactive "FWrite agenda to file: \nP")
(if (or (not (file-writable-p file)) (if (or (not (file-writable-p file))
(and (file-exists-p file) (and (file-exists-p file)
@ -3690,12 +3687,7 @@ the agenda to write."
(org-icalendar-export-current-agenda (expand-file-name file))) (org-icalendar-export-current-agenda (expand-file-name file)))
(t (t
(write-region nil nil file) (write-region nil nil file)
(message "Plain text written to %s" file))))))) (message "Plain text written to %s" file))))))))
(set-buffer (or agenda-bufname
;; FIXME: I'm pretty sure called-interactively-p
;; doesn't do what we want here!
(and (called-interactively-p 'any) (buffer-name))
org-agenda-buffer-name)))
(when open (org-open-file file))) (when open (org-open-file file)))
(defun org-agenda-remove-marked-text (property &optional value) (defun org-agenda-remove-marked-text (property &optional value)