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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read-abbrev-file function


From: Andreas Roehler
Subject: read-abbrev-file function
Date: Fri, 31 Mar 2006 21:27:35 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921

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


;; Proposed fix:
;; 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)
  (let* ((abbrevs-to-load file)
         (abbrevs-to-load (if abbrevs-to-load
                              abbrevs-to-load
                            ;; clear unavertedly inserted whitespaces
                            (string-strip (read-from-minibuffer (concat 
"(default:
"abbrev-file-name") ")) t t)))
         (abbrevs-to-load
          (if (string= abbrevs-to-load "")
              abbrev-file-name
            abbrevs-to-load)))
    (load abbrevs-to-load nil quietly))
  (setq abbrevs-changed nil))

;; Function needed to clear unavertedly
;; 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




reply via email to

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