[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: read-abbrev-file function
From: |
Andreas Roehler |
Subject: |
Re: read-abbrev-file function |
Date: |
Mon, 03 Apr 2006 09:29:02 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921 |
Richard Stallman wrote:
> Thanks for reporting the bug. I wrote a cleaner fix.
>
Please send copy of the fix, couldn't see it in the CVS-Rep.
AFAIS there is a related bug in abbrev.el, the fix
depends on the way `read-abbrev-file' is written:
;; Bugged: quietly-read-abbrev-file:
;; old: Interactive calls have been disabled from
;; quietly-read-abbrev-file, probably to avoid
;; disturbance caused by the
;; `f'-interactive-kontroll-letter bug
;; new: `interactive' reinstalled
(defun quietly-read-abbrev-file-ar (&optional file)
"Read abbrev definitions from file written with `write-abbrev-file'.
Optional argument FILE is the name of the file to read;
it defaults to the value of `abbrev-file-name'.
Does not display any message."
(interactive)
(read-abbrev-file-ar file t))
__
Andreas Roehler
PS.: Meanwhile I rewrote `read-abbrev-file' with
`cond', so its better to read:
(defun read-abbrev-file-ar (&optional file quietly)
"Read abbrev definitions from file written with `write-abbrev-file'.
Optional argument FILE is the name of the file to read;
it defaults to the value of `abbrev-file-name'.
Optional second argument QUIETLY non-nil means don't print anything."
(interactive)
(let* ((abbrevs-to-load
(cond ((when (boundp file)) file)
;; if quietly was specified but no file given,
;; load default abbrev-file
((when quietly
abbrev-file-name))
;; clear unavertedly inserted whitespaces
((string-strip
(read-from-minibuffer (concat "default: "
abbrev-file-name)) t t)))))
(when (string= abbrevs-to-load "")
(setq abbrevs-to-load abbrev-file-name))
(load abbrevs-to-load nil quietly))
(setq abbrevs-changed nil))
;; Function needed to clear unavertedly by users
;; inserted whitespaces
;; Source: comment-string-strip, newcomment.el, GNU Emacs 22.0.50.1;;
(defun string-strip (str beforep afterp)
"Strip STR of any leading (if BEFOREP) and/or trailing (if AFTERP) space.
"
(string-match (concat "\\`" (if beforep "\\s-*")
"\\(.*?\\)" (if afterp "\\s-*\n?")
"\\'") str)
(match-string 1 str))
;; end