mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
; * lisp/completion.el (load-completions-from-file): Simplify
Use a condition-case :success clause instead flags for control.
This commit is contained in:
parent
35610b870e
commit
b4173443fb
1 changed files with 49 additions and 53 deletions
|
|
@ -1917,68 +1917,64 @@ If file is not specified, then use `save-completions-file-name'."
|
|||
(clear-visited-file-modtime)
|
||||
(erase-buffer)
|
||||
|
||||
(let ((insert-okay-p nil)
|
||||
(buffer (current-buffer))
|
||||
(let ((buffer (current-buffer))
|
||||
string entry last-use-time
|
||||
cmpl-entry cmpl-last-use-time
|
||||
(current-completion-source cmpl-source-init-file)
|
||||
(total-in-file 0) (total-perm 0))
|
||||
;; insert the file into a buffer
|
||||
(condition-case nil
|
||||
(progn (insert-file-contents filename t)
|
||||
(setq insert-okay-p t))
|
||||
|
||||
(insert-file-contents filename t)
|
||||
(file-error
|
||||
(message "File error trying to load completion file %s."
|
||||
filename)))
|
||||
;; parse it
|
||||
(if insert-okay-p
|
||||
(progn
|
||||
(goto-char (point-min))
|
||||
filename))
|
||||
(:success
|
||||
;; parse it
|
||||
(goto-char (point-min))
|
||||
|
||||
(condition-case nil
|
||||
(while t
|
||||
(setq entry (read buffer))
|
||||
(setq total-in-file (1+ total-in-file))
|
||||
(cond
|
||||
((and (consp entry)
|
||||
(stringp (setq string (car entry)))
|
||||
(cond
|
||||
((eq (setq last-use-time (cdr entry)) 'T)
|
||||
;; handle case sensitivity
|
||||
(setq total-perm (1+ total-perm))
|
||||
(setq last-use-time t))
|
||||
((eq last-use-time t)
|
||||
(setq total-perm (1+ total-perm)))
|
||||
((integerp last-use-time))))
|
||||
;; Valid entry
|
||||
;; add it in
|
||||
(setq cmpl-last-use-time
|
||||
(completion-last-use-time
|
||||
(setq cmpl-entry
|
||||
(add-completion-to-tail-if-new string))))
|
||||
(if (or (eq last-use-time t)
|
||||
(and (> last-use-time 1000);;backcompatibility
|
||||
(not (eq cmpl-last-use-time t))
|
||||
(or (not cmpl-last-use-time)
|
||||
;; more recent
|
||||
(> last-use-time cmpl-last-use-time))))
|
||||
;; update last-use-time
|
||||
(set-completion-last-use-time cmpl-entry last-use-time)))
|
||||
(t
|
||||
;; Bad format
|
||||
(message "Error: invalid saved completion - %s"
|
||||
(prin1-to-string entry))
|
||||
;; try to get back in sync
|
||||
(search-forward "\n("))))
|
||||
(search-failed
|
||||
(message "End of file while reading completions."))
|
||||
(end-of-file
|
||||
(if (= (point) (point-max))
|
||||
(if (not no-message-p)
|
||||
(message "Loading completions from file %s . . . Done."
|
||||
filename))
|
||||
(message "End of file while reading completions."))))))
|
||||
(condition-case nil
|
||||
(while t
|
||||
(setq entry (read buffer))
|
||||
(setq total-in-file (1+ total-in-file))
|
||||
(cond
|
||||
((and (consp entry)
|
||||
(stringp (setq string (car entry)))
|
||||
(cond
|
||||
((eq (setq last-use-time (cdr entry)) 'T)
|
||||
;; handle case sensitivity
|
||||
(setq total-perm (1+ total-perm))
|
||||
(setq last-use-time t))
|
||||
((eq last-use-time t)
|
||||
(setq total-perm (1+ total-perm)))
|
||||
((integerp last-use-time))))
|
||||
;; Valid entry
|
||||
;; add it in
|
||||
(setq cmpl-last-use-time
|
||||
(completion-last-use-time
|
||||
(setq cmpl-entry
|
||||
(add-completion-to-tail-if-new string))))
|
||||
(if (or (eq last-use-time t)
|
||||
(and (> last-use-time 1000);;backcompatibility
|
||||
(not (eq cmpl-last-use-time t))
|
||||
(or (not cmpl-last-use-time)
|
||||
;; more recent
|
||||
(> last-use-time cmpl-last-use-time))))
|
||||
;; update last-use-time
|
||||
(set-completion-last-use-time cmpl-entry last-use-time)))
|
||||
(t
|
||||
;; Bad format
|
||||
(message "Error: invalid saved completion - %s"
|
||||
(prin1-to-string entry))
|
||||
;; try to get back in sync
|
||||
(search-forward "\n("))))
|
||||
(search-failed
|
||||
(message "End of file while reading completions."))
|
||||
(end-of-file
|
||||
(if (= (point) (point-max))
|
||||
(if (not no-message-p)
|
||||
(message "Loading completions from file %s . . . Done."
|
||||
filename))
|
||||
(message "End of file while reading completions."))))))
|
||||
))))))
|
||||
|
||||
(defun completion-initialize ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue