Add a simple list of labels
This commit is contained in:
parent
933febfeaa
commit
2427dc3138
1 changed files with 56 additions and 10 deletions
52
dispass.el
52
dispass.el
|
@ -4,7 +4,7 @@
|
|||
|
||||
;; Author: Tom Willemsen <tom@ryuslash.org>
|
||||
;; Created: Jun 8, 2012
|
||||
;; Version: 0.1a7.3
|
||||
;; Version: 1
|
||||
;; Keywords: encryption, security
|
||||
|
||||
;; Permission to use, copy, modify, and distribute this software for any
|
||||
|
@ -44,8 +44,8 @@
|
|||
;;; Customization:
|
||||
|
||||
;; dispass.el only offers customization of the `dispass-executable'
|
||||
;; variable for the moment. This is the location where the dispass
|
||||
;; executable is located.
|
||||
;; and `dispass-file' variables for the moment. This is the location
|
||||
;; where the dispass executable is located.
|
||||
|
||||
;;; Usage:
|
||||
|
||||
|
@ -89,6 +89,9 @@
|
|||
;; - Add a customization group named dispass, it is found
|
||||
;; under the "External" group.
|
||||
|
||||
;; 1 - Add `dispass-list-labels' which shows a list of all the labels
|
||||
;; in `dispass-file'.
|
||||
|
||||
;;; Code:
|
||||
(defgroup dispass nil
|
||||
"Customization options for the DisPass wrapper."
|
||||
|
@ -101,6 +104,12 @@
|
|||
:type '(string)
|
||||
:risky t)
|
||||
|
||||
(defcustom dispass-file "~/.dispass"
|
||||
"The location of your dispass file."
|
||||
:package-version '(dispass . "1")
|
||||
:group 'dispass
|
||||
:type '(file))
|
||||
|
||||
(defun dispass-process-sentinel (proc status)
|
||||
"Report PROC's status change to STATUS."
|
||||
(let ((status (substring status 0 -1))
|
||||
|
@ -168,6 +177,43 @@ an eye out for LABEL."
|
|||
"Recreate a password previously used."
|
||||
(dispass-start-process label nil length))
|
||||
|
||||
;; Labels management
|
||||
(defun dispass-labels--refresh ()
|
||||
"Reload labels from dispass."
|
||||
(setq tabulated-list-entries nil)
|
||||
|
||||
(let ((tmp-list '()))
|
||||
(with-temp-buffer
|
||||
(insert-file-contents dispass-file)
|
||||
(while (re-search-forward
|
||||
"\\(\\w+\\) .*length=\\([0-9]+\\) .*hash=\\(\\w+\\)$"
|
||||
nil t)
|
||||
(add-to-list 'tmp-list `(,(match-string 1)
|
||||
[,(match-string 1)
|
||||
,(match-string 2)
|
||||
,(match-string 3)]))))
|
||||
(setq tabulated-list-entries tmp-list)))
|
||||
|
||||
(define-derived-mode dispass-labels-mode tabulated-list-mode "DisPass"
|
||||
"Major mode for listing dispass labels."
|
||||
(setq tabulated-list-format [("Label" 30 t)
|
||||
("Length" 6 nil)
|
||||
("Hash" 0 t)]
|
||||
tabulated-list-sort-key '("Label" . nil))
|
||||
(add-hook 'tabulated-list-revert-hook 'dispass-labels--refresh)
|
||||
(tabulated-list-init-header))
|
||||
|
||||
(defun dispass-list-labels ()
|
||||
"Display a list of labels for dispass."
|
||||
(interactive)
|
||||
(let ((buffer (get-buffer-create "*DisPass Labels*")))
|
||||
(with-current-buffer buffer
|
||||
(dispass-labels-mode)
|
||||
(dispass-labels--refresh)
|
||||
(tabulated-list-print))
|
||||
(display-buffer buffer))
|
||||
nil)
|
||||
|
||||
(provide 'dispass)
|
||||
|
||||
;;; dispass.el ends here
|
||||
|
|
Loading…
Reference in a new issue