commit 24ae05251587fbba4687544ec57565c8bc48071a (HEAD, refs/remotes/origin/master) Author: Fabián Ezequiel Gallina Date: Sat Aug 22 20:42:04 2015 -0300 python.el: fallback completion, ffap and eldoc setup enhancements Setup codes are now sent continuously so that the current frame is always taken into account. This allows working within debuggers and always keeping a fresh version of setup codes that will return proper results. * lisp/progmodes/python.el (python-shell-setup-codes): Cleanup. (python-shell-send-setup-code): Send code only when python-shell-setup-codes is non-nil. (python-shell-completion-string-code): Cleanup trailing newline. (python-shell-completion-get-completions): Always use python-shell-completion-setup-code. (python-ffap-setup-code): Work with any object, not only modules. (python-ffap-string-code): Cleanup trailing newline. (python-ffap-module-path): Always use python-ffap-setup-code. (python-eldoc-string-code): Cleanup trailing newline. (python-eldoc--get-doc-at-point): Always use python-eldoc-setup-code. Return non-nil only if docstring is found. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index f65380b..3bfc5cf 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -2008,9 +2008,7 @@ virtualenv." (define-obsolete-variable-alias 'python-shell-virtualenv-path 'python-shell-virtualenv-root "25.1") -(defcustom python-shell-setup-codes '(python-shell-completion-setup-code - python-ffap-setup-code - python-eldoc-setup-code) +(defcustom python-shell-setup-codes nil "List of code run by `python-shell-send-setup-codes'." :type '(repeat symbol) :group 'python) @@ -3118,18 +3116,18 @@ t when called interactively." "Send all setup code for shell. This function takes the list of setup code to send from the `python-shell-setup-codes' list." - (let ((process (python-shell-get-process)) - (code (concat - (mapconcat - (lambda (elt) - (cond ((stringp elt) elt) - ((symbolp elt) (symbol-value elt)) - (t ""))) - python-shell-setup-codes - "\n\n") - "\n\nprint ('python.el: sent setup code')"))) - (python-shell-send-string code process) - (python-shell-accept-process-output process))) + (when python-shell-setup-codes + (let ((process (python-shell-get-process)) + (code (concat + (mapconcat + (lambda (elt) + (cond ((stringp elt) elt) + ((symbolp elt) (symbol-value elt)) + (t ""))) + python-shell-setup-codes + "\n\nprint ('python.el: sent setup code')")))) + (python-shell-send-string code process) + (python-shell-accept-process-output process)))) (add-hook 'inferior-python-mode-hook #'python-shell-send-setup-code) @@ -3187,7 +3185,7 @@ else: :group 'python) (defcustom python-shell-completion-string-code - "';'.join(__PYTHON_EL_get_completions('''%s'''))\n" + "';'.join(__PYTHON_EL_get_completions('''%s'''))" "Python code used to get a string of completions separated by semicolons. The string passed to the function is the current python name or the full statement in the case of imports." @@ -3490,28 +3488,22 @@ completion." ;; Check whether a prompt matches a pdb string, an import ;; statement or just the standard prompt and use the ;; correct python-shell-completion-*-code string - (cond ((and (string-match - (concat "^" python-shell-prompt-pdb-regexp) prompt)) - ;; Since there are no guarantees the user will remain - ;; in the same context where completion code was sent - ;; (e.g. user steps into a function), safeguard - ;; resending completion setup continuously. - (concat python-shell-completion-setup-code - "\nprint (" python-shell-completion-string-code ")")) - ((string-match - python-shell--prompt-calculated-input-regexp prompt) - python-shell-completion-string-code) - (t nil))) + (when (string-match python-shell--prompt-calculated-input-regexp prompt) + ;; Since there are no guarantees the user will remain + ;; in the same context where completion code was sent + ;; (e.g. user steps into a function), safeguard + ;; resending completion setup continuously. + (concat python-shell-completion-setup-code + "\nprint (" python-shell-completion-string-code ")"))) (subject (or import input))) - (and completion-code - (> (length input) 0) - (let ((completions - (python-util-strip-string - (python-shell-send-string-no-output - (format completion-code subject) process)))) - (and (> (length completions) 2) - (split-string completions - "^'\\|^\"\\|;\\|'$\\|\"$" t))))))) + (when (and completion-code (> (length input) 0)) + (let ((completions + (python-util-strip-string + (python-shell-send-string-no-output + (format completion-code subject) process)))) + (when (> (length completions) 2) + (split-string completions + "^'\\|^\"\\|;\\|'$\\|\"$" t))))))) (defun python-shell-completion-at-point (&optional process) "Function for `completion-at-point-functions' in `inferior-python-mode'. @@ -4055,13 +4047,22 @@ The skeleton will be bound to python-skeleton-NAME." ;;; FFAP (defcustom python-ffap-setup-code - "def __FFAP_get_module_path(module): + " +def __FFAP_get_module_path(objstr): try: - import os - path = __import__(module).__file__ - if path[-4:] == '.pyc' and os.path.exists(path[0:-1]): - path = path[:-1] - return path + import inspect + import os.path + # NameError exceptions are delayed until this point. + obj = eval(objstr) + module = inspect.getmodule(obj) + filename = module.__file__ + ext = os.path.splitext(filename)[1] + if ext in ('.pyc', '.pyo'): + # Point to the source file. + filename = filename[:-1] + if os.path.exists(filename): + return filename + return '' except: return ''" "Python code to get a module path." @@ -4069,7 +4070,7 @@ The skeleton will be bound to python-skeleton-NAME." :group 'python) (defcustom python-ffap-string-code - "__FFAP_get_module_path('''%s''')\n" + "__FFAP_get_module_path('''%s''')" "Python code used to get a string with the path of a module." :type 'string :group 'python) @@ -4084,9 +4085,12 @@ The skeleton will be bound to python-skeleton-NAME." nil (let ((module-file (python-shell-send-string-no-output - (format python-ffap-string-code module) process))) - (when module-file - (substring-no-properties module-file 1 -1)))))) + (concat + python-ffap-setup-code + "\nprint (" (format python-ffap-string-code module) ")") + process))) + (unless (zerop (length module-file)) + (python-util-strip-string module-file)))))) (defvar ffap-alist) @@ -4172,13 +4176,13 @@ See `python-check-command' for the default." doc = doc.splitlines()[0] except: doc = '' - print (doc)" + return doc" "Python code to setup documentation retrieval." :type 'string :group 'python) (defcustom python-eldoc-string-code - "__PYDOC_get_help('''%s''')\n" + "__PYDOC_get_help('''%s''')" "Python code used to get a string with the documentation of an object." :type 'string :group 'python) @@ -4204,15 +4208,20 @@ returns will be used. If not FORCE-PROCESS is passed what `python-shell-get-process' returns is used." (let ((process (or force-process (python-shell-get-process)))) (when process - (let ((input (or force-input - (python-eldoc--get-symbol-at-point)))) - (and input - ;; Prevent resizing the echo area when iPython is - ;; enabled. Bug#18794. - (python-util-strip-string - (python-shell-send-string-no-output - (format python-eldoc-string-code input) - process))))))) + (let* ((input (or force-input + (python-eldoc--get-symbol-at-point))) + (docstring + (when input + ;; Prevent resizing the echo area when iPython is + ;; enabled. Bug#18794. + (python-util-strip-string + (python-shell-send-string-no-output + (concat + python-eldoc-setup-code + "\nprint(" (format python-eldoc-string-code input) ")") + process))))) + (unless (zerop (length docstring)) + docstring))))) (defun python-eldoc-function () "`eldoc-documentation-function' for Python. commit 0a3ed5f70c6025fbc2a7e3ca53f11770e4fabe61 Author: Fabián Ezequiel Gallina Date: Sat Aug 22 19:05:31 2015 -0300 ; python.el: Fix typo for previous commit diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 7b755c6..f65380b 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3347,7 +3347,7 @@ def __PYTHON_EL_native_completion_setup(): readline.parse_and_bind('set show-all-if-ambiguous on') print ('python.el: readline is available') - except IOError: + except: print ('python.el: readline not available') __PYTHON_EL_native_completion_setup()" commit 34f58ce5d7ae8b716f8c9eee0f33d46dbcb2d9ef Author: Fabián Ezequiel Gallina Date: Sat Aug 22 18:07:26 2015 -0300 python.el: Increase native completion robustness. * lisp/progmodes/python.el (python-shell-completion-native-setup): Make completer print real candidates and just return dummy ones to avoid input modification. (python-shell-completion-native-get-completions): Set comint-redirect-insert-matching-regexp to non-nil and make comint-redirect-finished-regexp match the last dummy candidate. Use python-shell-accept-process-output to wait for the full list of candidates. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index d442dae..7b755c6 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -3252,48 +3252,78 @@ When a match is found, native completion is disabled." def __PYTHON_EL_native_completion_setup(): try: import readline + try: import __builtin__ except ImportError: # Python 3 import builtins as __builtin__ + builtins = dir(__builtin__) is_ipython = ('__IPYTHON__' in builtins or '__IPYTHON__active' in builtins) + class __PYTHON_EL_Completer: + '''Completer wrapper that prints candidates to stdout. + + It wraps an existing completer function and changes its behavior so + that the user input is unchanged and real candidates are printed to + stdout. + + Returned candidates are '0__dummy_completion__' and + '1__dummy_completion__' in that order ('0__dummy_completion__' is + returned repeatedly until all possible candidates are consumed). + + The real candidates are printed to stdout so that they can be + easily retrieved through comint output redirect trickery. + ''' + PYTHON_EL_WRAPPED = True + def __init__(self, completer): self.completer = completer self.last_completion = None + def __call__(self, text, state): if state == 0: - # The first completion is always a dummy completion. This - # ensures proper output for sole completions and a current - # input safeguard when no completions are available. + # Set the first dummy completion. self.last_completion = None completion = '0__dummy_completion__' else: completion = self.completer(text, state - 1) + if not completion: - if state == 1: - # When no completions are available, two non-sharing - # prefix strings are returned just to ensure output + if self.last_completion != '1__dummy_completion__': + # When no more completions are available, returning a + # dummy with non-sharing prefix allow to ensure output # while preventing changes to current input. + # Coincidentally it's also the end of output. completion = '1__dummy_completion__' - elif self.last_completion != '~~~~__dummy_completion__': - # This marks the end of output. - completion = '~~~~__dummy_completion__' elif completion.endswith('('): # Remove parens on callables as it breaks completion on # arguments (e.g. str(Ari)). completion = completion[:-1] self.last_completion = completion - return completion + + if completion in ( + '0__dummy_completion__', '1__dummy_completion__'): + return completion + elif completion: + # For every non-dummy completion, return a repeated dummy + # one and print the real candidate so it can be retrieved + # by comint output filters. + print (completion) + return '0__dummy_completion__' + else: + return completion + completer = readline.get_completer() + if not completer: # Used as last resort to avoid breaking customizations. import rlcompleter completer = readline.get_completer() + if completer and not getattr(completer, 'PYTHON_EL_WRAPPED', False): # Wrap the existing completer function only once. new_completer = __PYTHON_EL_Completer(completer) @@ -3308,15 +3338,18 @@ def __PYTHON_EL_native_completion_setup(): # function into the existing instance directly: instance = getattr(completer, 'im_self', completer.__self__) instance.rlcomplete = new_completer + if readline.__doc__ and 'libedit' in readline.__doc__: readline.parse_and_bind('bind ^I rl_complete') else: readline.parse_and_bind('tab: complete') # Require just one tab to send output. readline.parse_and_bind('set show-all-if-ambiguous on') + print ('python.el: readline is available') except IOError: print ('python.el: readline not available') + __PYTHON_EL_native_completion_setup()" process) (python-shell-accept-process-output process) @@ -3395,7 +3428,6 @@ completion." (original-filter-fn (process-filter process)) (redirect-buffer (get-buffer-create python-shell-completion-native-redirect-buffer)) - (separators (python-rx (or whitespace open-paren close-paren))) (trigger "\t") (new-input (concat input trigger)) (input-length @@ -3408,18 +3440,17 @@ completion." (unwind-protect (with-current-buffer redirect-buffer ;; Cleanup the redirect buffer - (delete-region (point-min) (point-max)) + (erase-buffer) ;; Mimic `comint-redirect-send-command', unfortunately it ;; can't be used here because it expects a newline in the ;; command and that's exactly what we are trying to avoid. (let ((comint-redirect-echo-input nil) - (comint-redirect-verbose nil) + (comint-redirect-completed nil) (comint-redirect-perform-sanity-check nil) - (comint-redirect-insert-matching-regexp nil) - ;; Feed it some regex that will never match. - (comint-redirect-finished-regexp "^\\'$") - (comint-redirect-output-buffer redirect-buffer) - (current-time (float-time))) + (comint-redirect-insert-matching-regexp t) + (comint-redirect-finished-regexp + "1__dummy_completion__[[:space:]]*\n") + (comint-redirect-output-buffer redirect-buffer)) ;; Compatibility with Emacs 24.x. Comint changed and ;; now `comint-redirect-filter' gets 3 args. This ;; checks which version of `comint-redirect-filter' is @@ -3433,21 +3464,17 @@ completion." (set-process-filter process #'comint-redirect-filter)) (process-send-string process input-to-send) ;; Grab output until our dummy completion used as - ;; output end marker is found. Output is accepted - ;; *very* quickly to keep the shell super-responsive. - (while (and (not (re-search-backward "~~~~__dummy_completion__" nil t)) - (< (- (float-time) current-time) - python-shell-completion-native-output-timeout)) - (accept-process-output process 0.01)) - (cl-remove-duplicates - (cl-remove-if - (lambda (c) - (string-match "__dummy_completion__" c)) - (split-string - (buffer-substring-no-properties - (point-min) (point-max)) - separators t)) - :test #'string=))) + ;; output end marker is found. + (when (python-shell-accept-process-output + process python-shell-completion-native-output-timeout + comint-redirect-finished-regexp) + (re-search-backward "0__dummy_completion__" nil t) + (cl-remove-duplicates + (split-string + (buffer-substring-no-properties + (line-beginning-position) (point-min)) + "[ \f\t\n\r\v()]+" t) + :test #'string=)))) (set-process-filter process original-filter-fn)))))) (defun python-shell-completion-get-completions (process import input) commit b0fe29ed920e65510ed062c5293c4db3b9a02ab6 Author: Eli Zaretskii Date: Sat Aug 22 22:14:56 2015 +0300 Fix invocation of programs via cmdproxy.exe * src/w32proc.c (sys_spawnve): Use exec-directory, not invocation-directory, for finding cmdproxy.exe. When Emacs is run from the source tree, look for cmdproxy.exe in the same source tree. (Bug#21323) diff --git a/src/w32proc.c b/src/w32proc.c index 66a9761..d861ede 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -1815,7 +1815,17 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) if (egetenv ("CMDPROXY")) strcpy (cmdname, egetenv ("CMDPROXY")); else - strcpy (lispstpcpy (cmdname, Vinvocation_directory), "cmdproxy.exe"); + { + char *q = lispstpcpy (cmdname, Vexec_directory); + /* If we are run from the source tree, use cmdproxy.exe from + the same source tree. */ + for (p = q - 2; p > cmdname; p--) + if (*p == '/') + break; + if (*p == '/' && xstrcasecmp (p, "/lib-src/") == 0) + q = stpcpy (p, "/nt/"); + strcpy (q, "cmdproxy.exe"); + } /* Can't use unixtodos_filename here, since that needs its file name argument encoded in UTF-8. */ commit 7372c1ab067ba93054fbb042cd13211042b83614 Author: Simen Heggestøyl Date: Sat Aug 22 19:13:10 2015 +0200 Handle comments inside unquoted URIs in css-mode * lisp/textmodes/css-mode.el (css--uri-re): New defconst. (css-syntax-propertize-function): New defconst. (css--font-lock-keywords): Handle parens around unquoted URIs. (css-mode): Set `syntax-propertize-function'. diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 424cdb7..d73780c 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -198,6 +198,16 @@ (modify-syntax-entry ?- "_" st) st)) +(eval-and-compile + (defconst css--uri-re + (concat + "url\\((\\)[[:space:]]*\\(?:\\\\.\\|[^()[:space:]\n'\"]\\)+" + "[[:space:]]*\\()\\)"))) + +(defconst css-syntax-propertize-function + (syntax-propertize-rules + (css--uri-re (1 "|") (2 "|")))) + (defconst css-escapes-re "\\\\\\(?:[^\000-\037\177]\\|[0-9a-fA-F]+[ \n\t\r\f]?\\)") (defconst css-nmchar-re (concat "\\(?:[-[:alnum:]]\\|" css-escapes-re "\\)")) @@ -278,7 +288,13 @@ "\\(?:\\(" css-proprietary-nmstart-re "\\)\\|" css-nmstart-re "\\)" css-nmchar-re "*" "\\)\\s-*:") - (1 (if (match-end 2) 'css-proprietary-property 'css-property))))) + (1 (if (match-end 2) 'css-proprietary-property 'css-property))) + ;; Make sure the parens in a url(...) expression receive the + ;; default face. This is done because the parens may sometimes + ;; receive generic string delimiter syntax (see + ;; `css-syntax-propertize-function'). + (,css--uri-re + (1 'default t) (2 'default t)))) (defvar css-font-lock-keywords (css--font-lock-keywords)) @@ -381,6 +397,8 @@ pseudo-classes, and at-rules." (setq-local comment-start-skip "/\\*+[ \t]*") (setq-local comment-end "*/") (setq-local comment-end-skip "[ \t]*\\*+/") + (setq-local syntax-propertize-function + css-syntax-propertize-function) (setq-local fill-paragraph-function #'css-fill-paragraph) (setq-local adaptive-fill-function #'css-adaptive-fill) (setq-local add-log-current-defun-function #'css-current-defun-name) commit ff42c71d054019dacace429204dfdf54111cb3d4 Author: Eli Zaretskii Date: Sat Aug 22 17:16:58 2015 +0300 Support invocation of Hunspell with multiple dictionaries * lisp/textmodes/ispell.el (ispell-parse-hunspell-affix-file): Support lists of dictionaries of the form "DICT1,DICT2,...". (ispell-hunspell-add-multi-dic): New command. (Bug#20495) diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 5831fc8..8627404 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -1195,44 +1195,81 @@ all uninitialized dicts using that affix file." (defun ispell-parse-hunspell-affix-file (dict-key) "Parse Hunspell affix file to extract parameters for DICT-KEY. -Return a list in `ispell-dictionary-alist' format." - (let ((affix-file (cadr (assoc dict-key ispell-hunspell-dict-paths-alist)))) - (unless affix-file - (error "ispell-phaf: No matching entry for %s.\n" dict-key)) - (if (not (file-exists-p affix-file)) - (error "ispell-phaf: File \"%s\" not found.\n" affix-file)) - (let ((dict-name (file-name-sans-extension - (file-name-nondirectory affix-file))) - otherchars-string otherchars-list) - (with-temp-buffer - (insert-file-contents affix-file) - (setq otherchars-string - (save-excursion - (goto-char (point-min)) - (if (search-forward-regexp "^WORDCHARS +" nil t ) - (buffer-substring (point) - (progn (end-of-line) (point)))))) - ;; Remove trailing whitespace and extra stuff. Make list if - ;; non-nil. - (setq otherchars-list - (if otherchars-string - (split-string - (if (string-match " +.*$" otherchars-string) - (replace-match "" nil nil otherchars-string) - otherchars-string) - "" t))) - - ;; Fill dict entry - (list dict-key - "[[:alpha:]]" - "[^[:alpha:]]" - (if otherchars-list - (regexp-opt otherchars-list) - "") - t ; many-otherchars-p: We can't tell, set to t. - (list "-d" dict-name) - nil ; extended-char-mode: not supported by hunspell! - 'utf-8))))) +Return a list in `ispell-dictionary-alist' format. + +DICT_KEY can be in the \"DICT1,DICT2,DICT3\" format, to invoke Hunspell +with a list of dictionaries. The first dictionary in the list must have +a corresponding .aff affix file; the rest are allowed to have no affix +files, and will then use the affix file of the preceding dictionary that +did." + (let ((dict-list (split-string dict-key "," t)) + (first-p t) + (dict-arg "") + otherchars-list) + (dolist (dict-key dict-list) + (let ((affix-file + (cadr (assoc dict-key ispell-hunspell-dict-paths-alist)))) + (unless affix-file + (error "ispell-phaf: No matching entry for %s in `ispell-hunspell-dict-paths-alist'.\n" dict-key)) + (if (and first-p (not (file-exists-p affix-file))) + (error "ispell-phaf: File \"%s\" not found.\n" affix-file)) + (and first-p (setq first-p nil)) + (let ((dict-name (file-name-sans-extension + (file-name-nondirectory affix-file))) + otherchars-string) + (with-temp-buffer + (insert-file-contents affix-file) + (setq otherchars-string + (save-excursion + (goto-char (point-min)) + (if (search-forward-regexp "^WORDCHARS +" nil t ) + (buffer-substring (point) + (progn (end-of-line) (point)))))) + ;; Remove trailing whitespace and extra stuff. Make list + ;; if non-nil. + (if otherchars-string + (let* ((otherchars-string + ;; Remove trailing junk. + (substring otherchars-string + 0 (string-match " +" otherchars-string))) + (chars-list (append otherchars-string nil))) + (setq chars-list (delq ?\ chars-list)) + (dolist (ch chars-list) + (add-to-list 'otherchars-list ch))))) + ;; Cons the argument for the -d switch. + (setq dict-arg (concat dict-arg + (if (> (length dict-arg) 0) ",") + dict-name))))) + + ;; Fill dict entry + (list dict-key + "[[:alpha:]]" + "[^[:alpha:]]" + (if otherchars-list + (regexp-opt (mapcar 'char-to-string otherchars-list)) + "") + t ; many-otherchars-p: We can't tell, set to t. + (list "-d" dict-arg) + nil ; extended-char-mode: not supported by hunspell! + 'utf-8))) + +(defun ispell-hunspell-add-multi-dic (dict) + "Add DICT of the form \"DICT1,DICT2,...\" to `ispell-dictionary-alist'. + +Invoke this command before you want to start Hunspell for the first time +with a particular combination of dictionaries. The first dictionary +in the list must have an affix file where Hunspell affix files are kept." + (interactive "sMulti-dictionary combination: ") + ;; Make sure the first dictionary in the list is known to us. + (let ((first-dict (car (split-string dict "," t)))) + (unless ispell-hunspell-dictionary-alist + (ispell-find-hunspell-dictionaries) + (setq ispell-dictionary-alist ispell-hunspell-dictionary-alist)) + (or (assoc first-dict ispell-local-dictionary-alist) + (assoc first-dict ispell-dictionary-alist) + (error "Unknown dictionary: %s" first-dict))) + (add-to-list 'ispell-dictionary-alist (list dict '())) + (ispell-hunspell-fill-dictionary-entry dict)) (defun ispell-find-hunspell-dictionaries () "Look for installed Hunspell dictionaries. commit 19efb9db0a03c453475f3b735d4f2e6fdfb853e4 Author: Eli Zaretskii Date: Sat Aug 22 13:38:51 2015 +0300 Minor formatting changes in ispell.el * lisp/textmodes/ispell.el (ispell-create-debug-buffer) (ispell-print-if-debug, ispell-aspell-find-dictionary) (ispell-aspell-add-aliases, ispell-hunspell-dict-paths-alist) (ispell-hunspell-dictionary-alist) (ispell-hunspell-fill-dictionary-entry) (ispell-find-hunspell-dictionaries, ispell-send-replacement) (ispell-buffer-with-debug, ispell-complete-word) (ispell-current-dictionary, ispell-current-personal-dictionary) (ispell-accept-output, ispell-minor-mode) (ispell-personal-dictionary, ispell-dictionary-alist) (ispell-really-aspell, ispell-really-hunspell) (ispell-encoding8-command, ispell-aspell-supports-utf8) (ispell-aspell-dictionary-alist, ispell-set-spellchecker-params): Fix whitespace, inconsistent capitalization, and arguments in doc strings. diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index b0fcb17..5831fc8 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -492,7 +492,7 @@ window system by evaluating the following on startup to set this variable: (defcustom ispell-personal-dictionary nil "File name of your personal spelling dictionary, or nil. If nil, the default personal dictionary, (\"~/.ispell_DICTNAME\" for ispell or -\"~/.aspell.LANG.pws\" for aspell) is used, where DICTNAME is the name of your +\"~/.aspell.LANG.pws\" for Aspell) is used, where DICTNAME is the name of your default dictionary and LANG the two letter language code." :type '(choice file (const :tag "default" nil)) @@ -747,29 +747,29 @@ when the language uses non-ASCII characters. Note that with \"ispell\" as the speller, the CASECHARS and OTHERCHARS slots of the alist should contain the same character set as casechars and otherchars in the LANGUAGE.aff file \(e.g., -english.aff\). aspell and hunspell don't have this limitation.") +english.aff\). Aspell and Hunspell don't have this limitation.") (defvar ispell-really-aspell nil - "Non-nil if we can use aspell extensions.") + "Non-nil if we can use Aspell extensions.") (defvar ispell-really-hunspell nil - "Non-nil if we can use hunspell extensions.") + "Non-nil if we can use Hunspell extensions.") (defvar ispell-encoding8-command nil "Command line option prefix to select encoding if supported, nil otherwise. If setting the encoding is supported by spellchecker and is selectable from -the command line, this variable will contain \"--encoding=\" for aspell -and \"-i \" for hunspell, so the appropriate mime charset can be selected. -That will be set in `ispell-check-version' for hunspell >= 1.1.6 and -aspell >= 0.60. +the command line, this variable will contain \"--encoding=\" for Aspell +and \"-i \" for Hunspell, so the appropriate mime charset can be selected. +That will be set in `ispell-check-version' for Hunspell >= 1.1.6 and +Aspell >= 0.60. -For aspell, non-nil also means to try to automatically find its dictionaries. +For Aspell, non-nil also means to try to automatically find its dictionaries. -Earlier aspell versions do not consistently support charset encoding. Handling +Earlier Aspell versions do not consistently support charset encoding. Handling this would require some extra guessing in `ispell-aspell-find-dictionary'.") (defvar ispell-aspell-supports-utf8 nil - "Non-nil if aspell has consistent command line UTF-8 support. Obsolete. + "Non-nil if Aspell has consistent command line UTF-8 support. Obsolete. ispell.el and flyspell.el will use for this purpose the more generic -variable `ispell-encoding8-command' for both aspell and hunspell. Is left +variable `ispell-encoding8-command' for both Aspell and Hunspell. Is left here just for backwards compatibility.") (make-obsolete-variable 'ispell-aspell-supports-utf8 @@ -944,7 +944,7 @@ Otherwise returns the library directory name, if that is defined." (defun ispell-create-debug-buffer (&optional append) "Create an ispell debug buffer for debugging output. -Use APPEND to append the info to previous buffer if exists, +If APPEND is non-nil, append the info to previous buffer if exists, otherwise is reset. Returns name of ispell debug buffer. See `ispell-buffer-with-debug' for an example of use." (let ((ispell-debug-buffer (get-buffer-create "*ispell-debug*"))) @@ -956,7 +956,7 @@ See `ispell-buffer-with-debug' for an example of use." ispell-debug-buffer)) (defsubst ispell-print-if-debug (format &rest args) - "Print message to `ispell-debug-buffer' buffer if enabled." + "Print message using FORMAT and ARGS to `ispell-debug-buffer' buffer if enabled." (if (boundp 'ispell-debug-buffer) (with-current-buffer ispell-debug-buffer (goto-char (point-max)) @@ -1009,13 +1009,13 @@ and added as a submenu of the \"Edit\" menu.") ;; Make ispell.el work better with aspell. (defvar ispell-aspell-dictionary-alist nil - "An alist of parsed aspell dicts and associated parameters. + "An alist of parsed Aspell dicts and associated parameters. Internal use.") (defun ispell-find-aspell-dictionaries () "Find Aspell's dictionaries, and record in `ispell-dictionary-alist'." (unless (and ispell-really-aspell ispell-encoding8-command) - (error "This function only works with aspell >= 0.60")) + (error "This function only works with Aspell >= 0.60")) (let* ((dictionaries (split-string (with-temp-buffer @@ -1053,7 +1053,7 @@ Assumes that value contains no whitespace." (car (split-string (buffer-string))))) (defun ispell-aspell-find-dictionary (dict-name) - "For aspell dictionary DICT-NAME, return a list of parameters if an + "For Aspell dictionary DICT-NAME, return a list of parameters if an associated data file is found or nil otherwise. List format is that of `ispell-dictionary-base-alist' elements." @@ -1119,7 +1119,7 @@ of `ispell-dictionary-base-alist' elements." 'utf-8))))) (defun ispell-aspell-add-aliases (alist) - "Find aspell's dictionary aliases and add them to dictionary ALIST. + "Find Aspell's dictionary aliases and add them to dictionary ALIST. Return the new dictionary alist." (let ((aliases (file-expand-wildcards @@ -1150,20 +1150,20 @@ Return the new dictionary alist." ;; Make ispell.el work better with hunspell. (defvar ispell-hunspell-dict-paths-alist nil - "Alist of parsed hunspell dicts and associated affix files. + "Alist of parsed Hunspell dicts and associated affix files. Will be used to parse corresponding .aff file and create associated parameters to be inserted into `ispell-hunspell-dictionary-alist'. Internal use.") (defvar ispell-hunspell-dictionary-alist nil - "Alist of parsed hunspell dicts and associated parameters. + "Alist of parsed Hunspell dicts and associated parameters. This alist will initially contain names of found dicts. Associated parameters will be added when dict is used for the first time. Internal use.") (defun ispell-hunspell-fill-dictionary-entry (dict) - "Fill `ispell-dictionary-alist' uninitialized entries for `DICT' and aliases. -Value will be extracted from hunspell affix file and used for + "Fill uninitialized entries in `ispell-dictionary-alist' for DICT and aliases. +Value of those entries will be extracted from Hunspell affix file and used for all uninitialized dicts using that affix file." (if (cadr (assoc dict ispell-dictionary-alist)) (message "ispell-hfde: Non void entry for %s. Skipping.\n" dict) @@ -1178,13 +1178,13 @@ all uninitialized dicts using that affix file." (dict-equiv-value (cadr dict-equiv-alist-entry))) (if (or (member dict dict-equiv-alist-entry) (member dict-alias dict-equiv-alist-entry)) - (dolist ( tmp-dict (list dict-equiv-key dict-equiv-value)) + (dolist (tmp-dict (list dict-equiv-key dict-equiv-value)) (if (cadr (assoc tmp-dict ispell-dictionary-alist)) (ispell-print-if-debug - "ispell-hfde: %s already expanded. Skipping.\n" tmp-dict) + "ispell-hfde: %s already expanded; skipping.\n" tmp-dict) (add-to-list 'use-for-dicts tmp-dict)))))) (ispell-print-if-debug - "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts) + "ispell-hfde: Filling %s entry. Use for %s.\n" dict use-for-dicts) ;; The final loop. (dolist (entry ispell-dictionary-alist) (if (member (car entry) use-for-dicts) @@ -1194,7 +1194,7 @@ all uninitialized dicts using that affix file." (setq ispell-dictionary-alist newlist)))) (defun ispell-parse-hunspell-affix-file (dict-key) - "Parse hunspell affix file to extract parameters for `DICT-KEY'. + "Parse Hunspell affix file to extract parameters for DICT-KEY. Return a list in `ispell-dictionary-alist' format." (let ((affix-file (cadr (assoc dict-key ispell-hunspell-dict-paths-alist)))) (unless affix-file @@ -1235,11 +1235,11 @@ Return a list in `ispell-dictionary-alist' format." 'utf-8))))) (defun ispell-find-hunspell-dictionaries () - "Look for installed hunspell dictionaries. + "Look for installed Hunspell dictionaries. Will initialize `ispell-hunspell-dictionary-alist' and `ispell-hunspell-dictionary-alist' after values found and remove `ispell-dicts-name2locale-equivs-alist' -entries if a specific dict was found." +entries if a specific dictionary was found." (let ((hunspell-found-dicts (split-string (with-temp-buffer @@ -1260,7 +1260,7 @@ entries if a specific dict was found." (if (string-match "\\.aff$" dict) ;; Found default dictionary (if hunspell-default-dict - (error "ispell-fhd: Default dict already defined as %s. Not using %s.\n" + (error "ispell-fhd: Default dict already defined as %s. Not using %s.\n" hunspell-default-dict dict) (setq affix-file dict) (setq hunspell-default-dict (list basename affix-file))) @@ -1280,7 +1280,7 @@ entries if a specific dict was found." (dolist (dict ispell-dicts-name2locale-equivs-alist) (if (assoc (car dict) ispell-hunspell-dict-paths-alist) (ispell-print-if-debug - "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n" + "-- ispell-fhd: Excluding %s alias. Standalone dict found.\n" (car dict)) (add-to-list 'newlist dict))) (setq ispell-dicts-name2locale-equivs-alist newlist)) @@ -1401,7 +1401,7 @@ aspell is used along with Emacs).") (setq ispell-args (nconc ispell-args (list "-d" dict-equiv))) (message - "ispell-set-spellchecker-params: Missing hunspell equiv for \"%s\". Skipping." + "ispell-set-spellchecker-params: Missing Hunspell equiv for \"%s\". Skipping." dict-name) (setq skip-dict t))) @@ -1619,12 +1619,12 @@ The variable `ispell-library-directory' defines their location." (defvar ispell-current-dictionary nil "The name of the current dictionary, or nil for the default. -This is passed to the ispell process using the `-d' switch and is +This is passed to the Ispell process using the `-d' switch and is used as key in `ispell-local-dictionary-alist' and `ispell-dictionary-alist'.") (defvar ispell-current-personal-dictionary nil "The name of the current personal dictionary, or nil for the default. -This is passed to the ispell process using the `-p' switch.") +This is passed to the Ispella process using the `-p' switch.") (defun ispell-decode-string (str) "Decodes multibyte character strings. @@ -1877,9 +1877,9 @@ You can set this variable in hooks in your init file -- eg: (defun ispell-accept-output (&optional timeout-secs timeout-msecs) - "Wait for output from ispell process, or TIMEOUT-SECS and TIMEOUT-MSECS. + "Wait for output from Ispell process, or TIMEOUT-SECS and TIMEOUT-MSECS. If asynchronous subprocesses are not supported, call function `ispell-filter' -and pass it the output of the last ispell invocation." +and pass it the output of the last Ispell invocation." (if ispell-async-processp (accept-process-output ispell-process timeout-secs timeout-msecs) (if (null ispell-process) @@ -1896,8 +1896,8 @@ and pass it the output of the last ispell invocation." (erase-buffer))))))) (defun ispell-send-replacement (misspelled replacement) - "Notify aspell that MISSPELLED should be spelled REPLACEMENT. -This allows it to improve the suggestion list based on actual misspellings." + "Notify Aspell that MISSPELLED should be spelled REPLACEMENT. +This allows to improve the suggestion list based on actual misspellings." (and ispell-really-aspell (ispell-send-string (concat "$$ra " misspelled "," replacement "\n")))) @@ -3702,7 +3702,7 @@ Returns the sum SHIFT due to changes in word replacements." ;;;###autoload (defun ispell-buffer-with-debug (&optional append) "`ispell-buffer' with some output sent to `ispell-debug-buffer' buffer. -Use APPEND to append the info to previous buffer if exists." +If APPEND is non-n il, append the info to previous buffer if exists." (interactive) (let ((ispell-debug-buffer (ispell-create-debug-buffer append))) (ispell-buffer))) @@ -3739,8 +3739,8 @@ Use APPEND to append the info to previous buffer if exists." ;;;###autoload (defun ispell-complete-word (&optional interior-frag) - "Try to complete the word before or under point. -If optional INTERIOR-FRAG is non-nil then the word may be a character + "Try to complete the word before or at point. +If optional INTERIOR-FRAG is non-nil, then the word may be a character sequence inside of a word. Standard ispell choices are then available." @@ -3846,7 +3846,7 @@ typing SPC or RET warns you if the previous word is incorrectly spelled. All the buffer-local variables and dictionaries are ignored. To -read them into the running ispell process, type \\[ispell-word] +read them into the running Ispell process, type \\[ispell-word] SPC. For spell-checking \"on the fly\", not just after typing SPC or