1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-03 08:30:09 +00:00

Derive secrets-mode from special-mode

* lisp/net/secrets.el: Remove top-level secrets-mode hack.
(secrets-mode-map): New variable.  Add key bindings to n and p for
navigating lines.
(secrets-mode): Derive from special-mode.  Remove keymap code and
initialization code.  Do not record undo information.  Make
secrets-show-collections the local revert-buffer-function.
(secrets-show-collections): Change signature to satisfy revert-buffer.
This commit is contained in:
Mark Oteiza 2016-07-08 21:10:32 -04:00
parent bdda4855c6
commit 7095596ac3

View File

@ -734,33 +734,30 @@ If there is no such item, or the item doesn't own this attribute, return nil."
;;; Visualization.
(define-derived-mode secrets-mode nil "Secrets"
(defvar secrets-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map (make-composed-keymap special-mode-map widget-keymap))
(define-key map "n" 'next-line)
(define-key map "p" 'previous-line)
(define-key map "z" 'kill-this-buffer)
map)
"Keymap used in `secrets-mode' buffers.")
(define-derived-mode secrets-mode special-mode "Secrets"
"Major mode for presenting password entries retrieved by Security Service.
In this mode, widgets represent the search results.
\\{secrets-mode-map}"
;; Keymap.
(setq secrets-mode-map (copy-keymap special-mode-map))
(set-keymap-parent secrets-mode-map widget-keymap)
(define-key secrets-mode-map "z" 'kill-this-buffer)
(setq buffer-undo-list t)
(set (make-local-variable 'revert-buffer-function)
#'secrets-show-collections)
;; When we toggle, we must set temporary widgets.
(set (make-local-variable 'tree-widget-after-toggle-functions)
'(secrets-tree-widget-after-toggle-function))
(when (not (called-interactively-p 'interactive))
;; Initialize buffer.
(setq buffer-read-only t)
(let ((inhibit-read-only t))
(erase-buffer))))
'(secrets-tree-widget-after-toggle-function)))
;; It doesn't make sense to call it interactively.
(put 'secrets-mode 'disabled t)
;; The very first buffer created with `secrets-mode' does not have the
;; keymap etc. So we create a dummy buffer. Stupid.
(with-temp-buffer (secrets-mode))
;; We autoload `secrets-show-secrets' only on systems with D-Bus support.
;;;###autoload(when (featurep 'dbusbind)
;;;###autoload (autoload 'secrets-show-secrets "secrets" nil t))
@ -783,7 +780,7 @@ to their attributes."
(secrets-mode)
(secrets-show-collections))))
(defun secrets-show-collections ()
(defun secrets-show-collections (&optional _ignore _noconfirm)
"Show all available collections."
(let ((inhibit-read-only t)
(alias (secrets-get-alias "default")))