Gnus -- minor build / warning fixes [OK For Upstream]
[gnus] / lisp / gnus-bookmark.el
index 1e76e3a..1bb9184 100644 (file)
@@ -1,26 +1,24 @@
 ;;; gnus-bookmark.el --- Bookmarks in Gnus
 
-;; Copyright (C) 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2016 Free Software Foundation, Inc.
 
 ;; Author: Bastien Guerry <bzg AT altern DOT org>
 ;; Keywords: news
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 ;; (define-key global-map "\C-crj" 'gnus-bookmark-jump)
 ;; (define-key global-map "\C-crl" 'gnus-bookmark-bmenu-list)
 
+;; FIXME: Add keybindings, see
+;; http://thread.gmane.org/gmane.emacs.gnus.general/63101/focus=63379
+;; http://thread.gmane.org/v9fxx9fkm4.fsf@marauder.physik.uni-ulm.de
+
+;; FIXME: Check if `gnus-bookmark.el' should use
+;; `bookmark-make-cell-function'.
+;; Cf. http://article.gmane.org/gmane.emacs.gnus.general/66076
+
 (defgroup gnus-bookmark nil
   "Setting, annotation and jumping to Gnus bookmarks."
   :group 'gnus)
@@ -95,7 +101,7 @@ List of details is defined in `gnus-bookmark-bookmark-inline-details'.
 This may result in truncated bookmark names.  To disable this, put the
 following in your `.emacs' file:
 
-\(setq gnus-bookmark-bmenu-toggle-infos nil\)"
+\(setq gnus-bookmark-bmenu-toggle-infos nil)"
   :type 'boolean
   :group 'gnus-bookmark)
 
@@ -112,7 +118,7 @@ You can toggle whether details are shown with \\<gnus-bookmark-bmenu-mode-map>\\
 
 (defcustom gnus-bookmark-bookmark-inline-details '(author)
   "Details to be shown with `gnus-bookmark-bmenu-toggle-infos'.
-The default value is \(subject\)."
+The default value is \(subject)."
   :type '(list :tag "Gnus bookmark details"
               (set :inline t
                    (const :tag "Author" author)
@@ -125,7 +131,7 @@ The default value is \(subject\)."
 (defcustom gnus-bookmark-bookmark-details
   '(author subject date group annotation)
   "Details to be shown with `gnus-bookmark-bmenu-show-details'.
-The default value is \(author subject date group annotation\)."
+The default value is \(author subject date group annotation)."
   :type '(list :tag "Gnus bookmark details"
               (set :inline t
                    (const :tag "Author" author)
@@ -139,7 +145,7 @@ The default value is \(author subject date group annotation\)."
 (defface gnus-bookmark-menu-heading
   '((t (:inherit font-lock-type-face)))
   "Face used to highlight the heading in Gnus bookmark menu buffers."
-  :version "23.0" ;; No Gnus
+  :version "23.1" ;; No Gnus
   :group 'gnus-bookmark)
 
 (defconst gnus-bookmark-end-of-version-stamp-marker
@@ -150,32 +156,29 @@ The default value is \(author subject date group annotation\)."
   "The current version of the format used by bookmark files.
 You should never need to change this.")
 
-(defvar gnus-bookmark-after-jump-hook nil
-  "Hook run after `gnus-bookmark-jump' jumps to a Gnus bookmark.")
-
 (defvar gnus-bookmark-alist ()
   "Association list of Gnus bookmarks and their records.
 The format of the alist is
 
-     \(BMK1 BMK2 ...\)
+     (BMK1 BMK2 ...)
 
 where each BMK is of the form
 
 \(NAME
-  \(group . GROUP\)
-  \(message-id . MESSAGE-ID\)
-  \(author . AUTHOR\)
-  \(date . DATE\)
-  \(subject . SUBJECT\)
-  \(annotation . ANNOTATION\)\)
+  (group . GROUP)
+  (message-id . MESSAGE-ID)
+  (author . AUTHOR)
+  (date . DATE)
+  (subject . SUBJECT)
+  (annotation . ANNOTATION))
 
 So the cdr of each bookmark is an alist too.")
 
 (defmacro gnus-bookmark-mouse-available-p ()
   "Return non-nil if a mouse is available."
   (if (featurep 'xemacs)
-      '(and (eq (device-class) 'color) (device-on-window-system-p))
-    '(and (display-color-p) (display-mouse-p))))
+      '(device-on-window-system-p)
+    '(display-mouse-p)))
 
 (defun gnus-bookmark-remove-properties (string)
   "Remove all text properties from STRING."
@@ -187,7 +190,7 @@ So the cdr of each bookmark is an alist too.")
   "Set a bookmark for this article."
   (interactive)
   (gnus-bookmark-maybe-load-default-file)
-  (if (or (not (eq major-mode 'gnus-summary-mode))
+  (if (or (not (derived-mode-p 'gnus-summary-mode))
          (not gnus-article-current))
       (error "Please select an article in the Gnus summary buffer")
     (let* ((group (car gnus-article-current))
@@ -207,13 +210,13 @@ So the cdr of each bookmark is an alist too.")
       (setq gnus-bookmark-alist
            (cons
             (list (gnus-bookmark-remove-properties bmk-name)
-                  (gnus-bookmark-make-cell
+                  (gnus-bookmark-make-record
                    group message-id author date subject annotation))
             gnus-bookmark-alist))))
   (gnus-bookmark-bmenu-surreptitiously-rebuild-list)
   (gnus-bookmark-write-file))
 
-(defun gnus-bookmark-make-cell
+(defun gnus-bookmark-make-record
   (group message-id author date subject annotation)
   "Return the record part of a new bookmark, given GROUP MESSAGE-ID AUTHOR DATE SUBJECT and ANNOTATION."
   (let ((the-record
@@ -248,7 +251,7 @@ So the cdr of each bookmark is an alist too.")
   (interactive)
   (save-excursion
     (save-window-excursion
-      ;; Avoir warnings?
+      ;; Avoid warnings?
       ;; (message "Saving Gnus bookmarks to file %s..." gnus-bookmark-default-file)
       (set-buffer (get-buffer-create  " *Gnus bookmarks*"))
       (erase-buffer)
@@ -286,11 +289,11 @@ So the cdr of each bookmark is an alist too.")
   (interactive)
   (gnus-bookmark-maybe-load-default-file)
   (let* ((bookmark (or bmk-name
-         (completing-read "Jump to bookmarked article: "
-                          gnus-bookmark-alist)))
-        (bmk-cell (cadr (assoc bookmark gnus-bookmark-alist)))
-        (group (cdr (assoc 'group bmk-cell)))
-        (message-id (cdr (assoc 'message-id bmk-cell))))
+                       (gnus-completing-read "Jump to bookmarked article"
+                                             (mapcar 'car gnus-bookmark-alist))))
+        (bmk-record (cadr (assoc bookmark gnus-bookmark-alist)))
+        (group (cdr (assoc 'group bmk-record)))
+        (message-id (cdr (assoc 'message-id bmk-record))))
     (when group
       (unless (get-buffer gnus-group-buffer)
        (gnus-no-server))
@@ -364,11 +367,11 @@ The leftmost column displays a D if the bookmark is flagged for
 deletion, or > if it is flagged for displaying."
   (interactive)
   (gnus-bookmark-maybe-load-default-file)
-  (if (interactive-p)
+  (if (gmm-called-interactively-p 'any)
       (switch-to-buffer (get-buffer-create "*Gnus Bookmark List*"))
     (set-buffer (get-buffer-create "*Gnus Bookmark List*")))
   (let ((inhibit-read-only t)
-       alist name start end)
+       alist name)
     (erase-buffer)
     (insert "% Gnus Bookmark\n- --------\n")
     (add-text-properties (point-min) (point)
@@ -429,7 +432,7 @@ That is, all information but the name."
   (car (cdr (gnus-bookmark-get-bookmark bookmark))))
 
 (defun gnus-bookmark-name-from-full-record (full-record)
-  "Return name of FULL-RECORD \(an alist element instead of a string\)."
+  "Return name of FULL-RECORD (an alist element instead of a string)."
   (car full-record))
 
 (defvar gnus-bookmark-bmenu-bookmark-column nil)
@@ -470,7 +473,7 @@ That is, all information but the name."
 ;; Been to lazy to use gnus-bookmark-save...
 (defalias 'gnus-bookmark-bmenu-save 'gnus-bookmark-write-file)
 
-(defun gnus-bookmark-bmenu-mode ()
+(define-derived-mode gnus-bookmark-bmenu-mode fundamental-mode "Bookmark Menu"
   "Major mode for editing a list of Gnus bookmarks.
 Each line describes one of the bookmarks in Gnus.
 Letters do not insert themselves; instead, they are commands.
@@ -481,7 +484,7 @@ Gnus bookmarks names preceded by a \"*\" have annotations.
   Also show bookmarks marked using m in other windows.
 \\[gnus-bookmark-bmenu-toggle-infos] -- toggle displaying of details (they may obscure long bookmark names).
 \\[gnus-bookmark-bmenu-locate] -- display (in minibuffer) location of this bookmark.
-\\[gnus-bookmark-bmenu-rename] -- rename this bookmark \(prompts for new name\).
+\\[gnus-bookmark-bmenu-rename] -- rename this bookmark (prompts for new name).
 \\[gnus-bookmark-bmenu-delete] -- mark this bookmark to be deleted, and move down.
 \\[gnus-bookmark-bmenu-delete-backwards] -- mark this bookmark to be deleted, and move up.
 \\[gnus-bookmark-bmenu-execute-deletions] -- delete bookmarks marked with `\\[gnus-bookmark-bmenu-delete]'.
@@ -494,13 +497,8 @@ Gnus bookmarks names preceded by a \"*\" have annotations.
   in another buffer.
 \\[gnus-bookmark-bmenu-show-all-annotations] -- show the annotations of all bookmarks in another buffer.
 \\[gnus-bookmark-bmenu-edit-annotation] -- edit the annotation for the current bookmark."
-  (kill-all-local-variables)
-  (use-local-map gnus-bookmark-bmenu-mode-map)
   (setq truncate-lines t)
-  (setq buffer-read-only t)
-  (setq major-mode 'gnus-bookmark-bmenu-mode)
-  (setq mode-name "Bookmark Menu")
-  (gnus-run-mode-hooks 'gnus-bookmark-bmenu-mode-hook))
+  (setq buffer-read-only t))
 
 ;; avoid compilation warnings
 (defvar gnus-bookmark-bmenu-toggle-infos nil)
@@ -535,7 +533,7 @@ Optional argument SHOW means show them unconditionally."
             (let ((bmrk (gnus-bookmark-bmenu-bookmark)))
               (setq gnus-bookmark-bmenu-hidden-bookmarks
                     (cons bmrk gnus-bookmark-bmenu-hidden-bookmarks))
-             (let ((start (save-excursion (end-of-line) (point))))
+             (let ((start (point-at-eol)))
                (move-to-column gnus-bookmark-bmenu-file-column t)
                ;; Strip off `mouse-face' from the white spaces region.
                (if (gnus-bookmark-mouse-available-p)
@@ -569,10 +567,9 @@ Optional argument SHOW means show them unconditionally."
   "Kill from point to end of line.
 If optional arg NEWLINE-TOO is non-nil, delete the newline too.
 Does not affect the kill ring."
-  (let ((eol (save-excursion (end-of-line) (point))))
-    (delete-region (point) eol)
-    (if (and newline-too (looking-at "\n"))
-        (delete-char 1))))
+  (delete-region (point) (point-at-eol))
+  (if (and newline-too (looking-at "\n"))
+      (delete-char 1)))
 
 (defun gnus-bookmark-get-details (bmk-name details-list)
   "Get details for a Gnus BMK-NAME depending on DETAILS-LIST."
@@ -809,7 +806,7 @@ command."
 Removes only the first instance of a bookmark with that name.  If
 there are one or more other bookmarks with the same name, they will
 not be deleted.  Defaults to the \"current\" bookmark \(that is, the
-one most recently used in this file, if any\).
+one most recently used in this file, if any).
 Optional second arg BATCH means don't update the bookmark list buffer,
 probably because we were called from there."
   (gnus-bookmark-maybe-load-default-file)
@@ -822,5 +819,4 @@ probably because we were called from there."
 
 (provide 'gnus-bookmark)
 
-;; arch-tag: 779df694-366f-46e8-84b2-1d0340e6f525
 ;;; gnus-bookmark.el ends here