emacs-pretest-bug
[Top][All Lists]
Advanced

[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 22:00:30 +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.
> 

Until it's in the CVS-rep; Here the present state of art:

;; Bugged: read-abbrev-file function in abbrev.el

;; The `(interactive "f' - kontroll-letter takes just
;; the current buffer-file if you quit the demand
;; with RET.  That's not what you want: If the file is
;; already open, there is no need to call
;; `read-abbrev-file', the `default-abbrev-file' should
;; be called in the case of no specified user input.

;; Fixed:
;; Loads the default-abbrev-file unless no file is specified.

(defalias 'read-abbrev-file 'read-abbrev-file-ar)

(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
   (list
    ;; clear unavertedly inserted whitespaces
    (string-strip
     (read-from-minibuffer (concat "default: " abbrev-file-name)) t t)))
  (load (if (and file (> (length file) 0)) file abbrev-file-name)
        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))

;; Bugged: quietly-read-abbrev-file:

;; old:
;; Interactive calls have been disabled from
;; quietly-read-abbrev-file, probably to avoid the bug
;; with the `f'-interactive-kontroll-letter

;; 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))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]