Add support for the -f switch

The option `dispass-labelfile' specifies the labelfile you would like
to use instead of the one provided by DisPass itself.

These changes should be cleaned up later, but for now it works.
This commit is contained in:
Tom Willemsen 2013-01-20 15:58:35 +01:00
parent 3a9d333ecf
commit 2079e6c4b3

View file

@ -53,6 +53,14 @@
:type 'string :type 'string
:risky t) :risky t)
(defcustom dispass-labelfile nil
"The location of your preferred labelfile, a value of `nil'
means to just let DisPass figure it out."
:package-version '(dispass . "1.1.1")
:group 'dispass
:type 'file
:risky t)
(defvar dispass-labels-mode-map (defvar dispass-labels-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
(set-keymap-parent map tabulated-list-mode-map) (set-keymap-parent map tabulated-list-mode-map)
@ -132,6 +140,9 @@ an eye out for LABEL."
(when (and seqno (> seqno 0)) (when (and seqno (> seqno 0))
(setq args (append `("-n" ,(number-to-string seqno)) args))) (setq args (append `("-n" ,(number-to-string seqno)) args)))
(when dispass-labelfile
(setq args (append `("-f" ,dispass-labelfile) args)))
(setq proc (apply 'start-process "dispass" "*dispass*" (setq proc (apply 'start-process "dispass" "*dispass*"
dispass-executable args)) dispass-executable args))
(set-process-sentinel proc 'dispass-process-sentinel) (set-process-sentinel proc 'dispass-process-sentinel)
@ -175,7 +186,10 @@ an eye out for LABEL."
(defun dispass-read-labels () (defun dispass-read-labels ()
"Load a list of all labels into a buffer." "Load a list of all labels into a buffer."
(insert (shell-command-to-string (insert (shell-command-to-string
(concat dispass-labels-executable " -l --script"))) (concat dispass-labels-executable
(when dispass-labelfile
(concat " -f " dispass-labelfile))
" -l --script")))
(goto-char (point-min))) (goto-char (point-min)))
;;;###autoload ;;;###autoload
@ -221,8 +235,12 @@ an eye out for LABEL."
dispass-algorithms nil nil nil nil "dispass1") dispass-algorithms nil nil nil nil "dispass1")
(read-from-minibuffer "Sequnce no. (1): " nil nil t nil "1"))) (read-from-minibuffer "Sequnce no. (1): " nil nil t nil "1")))
(shell-command (shell-command
(format "%s --add %s:%d:%s:%s" (format "%s %s --add %s:%d:%s:%s"
dispass-labels-executable label length algo seqno))) dispass-labels-executable
(if dispass-labelfile
(concat "-f " dispass-labelfile)
"")
label length algo seqno)))
;;;###autoload ;;;###autoload
(defun dispass-remove-label (label) (defun dispass-remove-label (label)
@ -235,7 +253,11 @@ thrown."
(completing-read (completing-read
"Label: " (dispass-get-labels))))) "Label: " (dispass-get-labels)))))
(shell-command (shell-command
(format "%s --remove %s" dispass-labels-executable label))) (format "%s %s --remove %s" dispass-labels-executable
(if dispass-labelfile
(concat "-f " dispass-labelfile)
"")
label)))
(defun dispass-from-button (button) (defun dispass-from-button (button)
"Call dispass with information from BUTTON." "Call dispass with information from BUTTON."