emacs-diffs
[Top][All Lists]
Advanced

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

master 454c06a22c 06/10: Fix namespace use in bib-mode.el


From: Stefan Kangas
Subject: master 454c06a22c 06/10: Fix namespace use in bib-mode.el
Date: Sat, 30 Jul 2022 06:12:06 -0400 (EDT)

branch: master
commit 454c06a22c8b2ddb177d2e613807fc206ba29da7
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    Fix namespace use in bib-mode.el
    
    * lisp/textmodes/bib-mode.el (bib-unread-file, bib-add)
    (bib-return-key, bib-mark, bib-unread): Rename from
    'unread-bib-file', 'addbib', 'return-key-bib', 'mark-bib', and
    'unread-bib' respectively.  Maintain old names as obsolete aliases and
    update uses.
    (bib-mode-map): Prefer defvar-keymap.
---
 etc/NEWS                   | 10 +++++++
 lisp/textmodes/bib-mode.el | 68 ++++++++++++++++++++++++----------------------
 2 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index b6f77e3e49..f7cfae30f3 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2181,6 +2181,16 @@ instead of also trying to ping it.  Customize the user 
option
 ---
 *** The 'run-dig' command is now obsolete; use 'dig' instead.
 
+---
+*** Some `bib-mode' commands and variables have been renamed.
+To respect Emacs naming conventions, the variable 'unread-bib-file'
+has been renamed to 'bib-unread-file'.  The following commands have
+also been renamed:
+  'addbib'           to  'bib-add'
+  'return-key-bib'   to  'bib-return-key'
+  'mark-bib'         to  'bib-mark'
+  'unread-bib'       to  'bib-unread'
+
 ---
 ** The autoarg.el library is now marked obsolete.
 This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor
diff --git a/lisp/textmodes/bib-mode.el b/lisp/textmodes/bib-mode.el
index 6168fed6c8..21a4dc751a 100644
--- a/lisp/textmodes/bib-mode.el
+++ b/lisp/textmodes/bib-mode.el
@@ -24,12 +24,10 @@
 
 ;;; Commentary:
 
-;;   GNU Emacs code to help maintain databases compatible with (troff)
-;;   refer and lookbib.  The file bib-file should be set to your
-;;   bibliography file.  Keys are automagically inserted as you type,
-;;   and appropriate keys are presented for various kinds of entries.
-
-;; FIXME: Fix the namespace use of this library.
+;; GNU Emacs code to help maintain databases compatible with (troff)
+;; refer and lookbib.  The file `bib-file' should be set to your
+;; bibliography file.  Keys are automagically inserted as you type,
+;; and appropriate keys are presented for various kinds of entries.
 
 ;;; Code:
 
@@ -40,23 +38,23 @@
   :group 'text)
 
 (defcustom bib-file "~/my-bibliography.bib"
-  "Default name of file used by `addbib'."
+  "Default name of file used by `bib-add'."
   :type 'file)
 
-(defcustom unread-bib-file "~/to-be-read.bib"
-   "Default name of file used by `unread-bib' in Bib mode."
-   :type 'file)
+(define-obsolete-variable-alias 'unread-bib-file 'bib-unread-file "29.1")
+(defcustom bib-unread-file "~/to-be-read.bib"
+  "Default name of file used by `bib-unread' in Bib mode."
+  :type 'file
+  :version "29.1")
 
-(defvar bib-mode-map
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map text-mode-map)
-    (define-key map "\C-M" #'return-key-bib)
-    (define-key map "\C-c\C-u" #'unread-bib)
-    (define-key map "\C-c\C-@" #'mark-bib)
-    (define-key map "\e`" #'abbrev-mode)
-    map))
+(defvar-keymap bib-mode-map
+  :parent text-mode-map
+  "RET"     #'bib-return-key
+  "C-c C-u" #'bib-unread
+  "C-c C-@" #'bib-mark
+  "M-`"     #'abbrev-mode)
 
-(defun addbib ()
+(defun bib-add ()
    "Set up editor to add to troff bibliography file specified
 by global variable `bib-file'.  See description of `bib-mode'."
    (interactive)
@@ -87,10 +85,10 @@ R eport number or `phd thesis' or `masters thesis' or 
`draft' or
 W here can be found locally (login name, or ailib, etc.)
 X comments (not used in indexing)
 
-\\[unread-bib] appends current entry to a different file (for example,
+\\[bib-unread] appends current entry to a different file (for example,
 a file of papers to be read in the future), given by the value of the
-variable `unread-bib-file'.
-\\[mark-bib] marks current or previous entry.
+variable `bib-unread-file'.
+\\[bib-mark] marks current or previous entry.
 Abbreviations are saved in `bib-mode-abbrev-table'.
 Hook can be stored in `bib-mode-hook'.
 Field keys given by variable `bib-assoc'.
@@ -142,7 +140,7 @@ with the cdr.")
 
 (defconst bib-capitalized-fields "%[AETCBIJR]")
 
-(defun return-key-bib ()
+(defun bib-return-key ()
   "Magic when user hits return, used by `bib-mode'."
   (interactive)
   (if (eolp)
@@ -172,7 +170,7 @@ with the cdr.")
       (insert new-key))
     (newline)))
 
-(defun mark-bib ()
+(defun bib-mark ()
    "Set mark at beginning of current or previous bib entry, point at end."
    (interactive)
    (beginning-of-line nil)
@@ -185,14 +183,14 @@ with the cdr.")
    (forward-line 1)
    (beginning-of-line nil))
 
-(defun unread-bib ()
-   "Append current or previous entry to file of unread papers
-named by variable `unread-bib-file'."
-   (interactive)
-   (mark-bib)
-   (if (get-file-buffer unread-bib-file)
-      (append-to-buffer (get-file-buffer unread-bib-file) (mark) (point))
-      (append-to-file (mark) (point) unread-bib-file)))
+(defun bib-unread ()
+  "Append current or previous entry to file of unread papers
+named by variable `bib-unread-file'."
+  (interactive)
+  (bib-mark)
+  (if (get-file-buffer bib-unread-file)
+      (append-to-buffer (get-file-buffer bib-unread-file) (mark) (point))
+    (append-to-file (mark) (point) bib-unread-file)))
 
 
 (defvar bib-capitalize-title-stop-words
@@ -226,7 +224,6 @@ named by variable `unread-bib-file'."
               ))
         (set-syntax-table orig-syntax-table))))
 
-
 (defun bib-capitalize-title (s)
    "Like `capitalize', but don't capitalize stop words, except the first."
    (with-current-buffer (get-buffer-create "$$$Scratch$$$")
@@ -235,6 +232,11 @@ named by variable `unread-bib-file'."
      (bib-capitalize-title-region (point-min) (point-max))
      (buffer-string)))
 
+(define-obsolete-function-alias 'addbib #'bib-add "29.1")
+(define-obsolete-function-alias 'return-key-bib #'bib-return-key "29.1")
+(define-obsolete-function-alias 'mark-bib #'bib-mark "29.1")
+(define-obsolete-function-alias 'unread-bib #'bib-unread "29.1")
+
 (provide 'bib-mode)
 
 ;;; bib-mode.el ends here



reply via email to

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