aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2007-03-20 16:23:09 +0000
committerRichard M. Stallman2007-03-20 16:23:09 +0000
commitbc4c663309d53cfeafb17f596fc8f47f7fb483c6 (patch)
treec9c2e3426f184af619f2768a995681dcbc39bacb
parenta8b145e3578d467150ab11113f4ca0ec753c2cb7 (diff)
downloademacs-bc4c663309d53cfeafb17f596fc8f47f7fb483c6.tar.gz
emacs-bc4c663309d53cfeafb17f596fc8f47f7fb483c6.zip
(ispell-call-process): New function.
Defends against bad `default-directory.' (ispell-check-version, ispell-find-aspell-dictionaries) (ispell-get-aspell-config-value, lookup-words): Call it. (ispell-call-process-region): New function. (ispell-send-string): Call it.
-rw-r--r--lisp/textmodes/ispell.el29
1 files changed, 22 insertions, 7 deletions
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 73faea4e9c2..a3c9575d90c 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -766,9 +766,7 @@ Otherwise returns the library directory name, if that is defined."
766 (if buf (kill-buffer buf))) 766 (if buf (kill-buffer buf)))
767 (set-buffer (get-buffer-create " *ispell-tmp*")) 767 (set-buffer (get-buffer-create " *ispell-tmp*"))
768 (erase-buffer) 768 (erase-buffer)
769 (unless (file-exists-p default-directory) 769 (setq status (ispell-call-process
770 (setq default-directory (expand-file-name "~/")))
771 (setq status (call-process
772 ispell-program-name nil t nil 770 ispell-program-name nil t nil
773 ;; aspell doesn't accept the -vv switch. 771 ;; aspell doesn't accept the -vv switch.
774 (let ((case-fold-search 772 (let ((case-fold-search
@@ -827,6 +825,22 @@ Otherwise returns the library directory name, if that is defined."
827 (kill-buffer (current-buffer))) 825 (kill-buffer (current-buffer)))
828 result)) 826 result))
829 827
828(defun ispell-call-process (&rest args)
829 "Like `call-process' but defend against bad `default-directory'."
830 (let ((default-directory default-directory))
831 (unless (and (file-directory-p default-directory)
832 (file-readable-p default-directory))
833 (setq default-directory (expand-file-name "~/")))
834 (apply 'call-process args)))
835
836(defun ispell-call-process-region (&rest args)
837 "Like `call-process-region' but defend against bad `default-directory'."
838 (let ((default-directory default-directory))
839 (unless (and (file-directory-p default-directory)
840 (file-readable-p default-directory))
841 (setq default-directory (expand-file-name "~/")))
842 (apply 'call-process-region args)))
843
830 844
831 845
832;;; The preparation of the menu bar menu must be autoloaded 846;;; The preparation of the menu bar menu must be autoloaded
@@ -895,7 +909,7 @@ and added as a submenu of the \"Edit\" menu.")
895 (let* ((dictionaries 909 (let* ((dictionaries
896 (split-string 910 (split-string
897 (with-temp-buffer 911 (with-temp-buffer
898 (call-process ispell-program-name nil t nil "dicts") 912 (ispell-call-process ispell-program-name nil t nil "dicts")
899 (buffer-string)))) 913 (buffer-string))))
900 ;; Search for the named dictionaries. 914 ;; Search for the named dictionaries.
901 (found 915 (found
@@ -928,7 +942,7 @@ and added as a submenu of the \"Edit\" menu.")
928 "Return value of Aspell configuration option KEY. 942 "Return value of Aspell configuration option KEY.
929Assumes that value contains no whitespace." 943Assumes that value contains no whitespace."
930 (with-temp-buffer 944 (with-temp-buffer
931 (call-process ispell-program-name nil t nil "config" key) 945 (ispell-call-process ispell-program-name nil t nil "config" key)
932 (car (split-string (buffer-string))))) 946 (car (split-string (buffer-string)))))
933 947
934(defun ispell-aspell-find-dictionary (dict-name) 948(defun ispell-aspell-find-dictionary (dict-name)
@@ -1500,7 +1514,8 @@ This allows it to improve the suggestion list based on actual mispellings."
1500 (erase-buffer) 1514 (erase-buffer)
1501 (set-buffer session-buf) 1515 (set-buffer session-buf)
1502 (setq status 1516 (setq status
1503 (apply 'call-process-region (point-min) (point-max) 1517 (apply 'ispell-call-process-region
1518 (point-min) (point-max)
1504 ispell-program-name nil 1519 ispell-program-name nil
1505 output-buf nil 1520 output-buf nil
1506 "-a" "-m" ispell-args)) 1521 "-a" "-m" ispell-args))
@@ -2197,7 +2212,7 @@ Optional second argument contains the dictionary to use; the default is
2197 (while (search-backward "*" nil t) (insert ".")) 2212 (while (search-backward "*" nil t) (insert "."))
2198 (setq word (buffer-string)) 2213 (setq word (buffer-string))
2199 (erase-buffer)) 2214 (erase-buffer))
2200 (setq status (apply 'call-process prog nil t nil 2215 (setq status (apply 'ispell-call-process prog nil t nil
2201 (nconc (if (and args (> (length args) 0)) 2216 (nconc (if (and args (> (length args) 0))
2202 (list args) 2217 (list args)
2203 (if look-p nil 2218 (if look-p nil