From: Reuben Thomas Date: Mon, 2 Nov 2020 21:45:40 +0000 (+0000) Subject: Factor out some common code in ispell.el X-Git-Tag: emacs-28.0.90~5262 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f9d6e463d310db0e1931f26609d938531c56f9c3;p=emacs.git Factor out some common code in ispell.el * lisp/textmodes/ispell.el (ispell-with-safe-default-directory): Add macro. (ispell-call-process, ispell-call-process-region): Use it. --- diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 60415b02b8b..c185f9f2c81 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -769,18 +769,23 @@ Otherwise returns the library directory name, if that is defined." (setq ispell-really-hunspell nil)))))) result)) +(defmacro ispell-with-safe-default-directory (&rest body) + "Execute the forms in BODY with a reasonable +`default-directory'." + (declare (indent 0) (debug t)) + `(let ((default-directory default-directory)) + (unless (file-accessible-directory-p default-directory) + (setq default-directory (expand-file-name "~/"))) + ,@body)) + (defun ispell-call-process (&rest args) - "Like `call-process' but defend against bad `default-directory'." - (let ((default-directory default-directory)) - (unless (file-accessible-directory-p default-directory) - (setq default-directory (expand-file-name "~/"))) + "Like `call-process', but defend against bad `default-directory'." + (ispell-with-safe-default-directory (apply 'call-process args))) (defun ispell-call-process-region (&rest args) - "Like `call-process-region' but defend against bad `default-directory'." - (let ((default-directory default-directory)) - (unless (file-accessible-directory-p default-directory) - (setq default-directory (expand-file-name "~/"))) + "Like `call-process-region', but defend against bad `default-directory'." + (ispell-with-safe-default-directory (apply 'call-process-region args))) (defvar ispell-debug-buffer)