diff options
author | Tom Willemsen | 2012-07-08 16:05:07 +0200 |
---|---|---|
committer | Tom Willemsen | 2012-07-08 16:05:07 +0200 |
commit | 9bd8cdaaa503ca821488aea9cd16ff6601b9c8a3 (patch) | |
tree | daa9f361b17909c522a3f39e6c8d411eaf58ed73 | |
parent | d7d34799d4f347d45445fba75ad91b503b728bc9 (diff) | |
download | dispass.el-9bd8cdaaa503ca821488aea9cd16ff6601b9c8a3.tar.gz dispass.el-9bd8cdaaa503ca821488aea9cd16ff6601b9c8a3.zip |
Add function to remove label from labels file
* dispass.el (dispass-remove-label): Removes the given or pointed-at
label from `dispass-file'. When no label is found it will throw an
error.
(dispass-labels-mode-map): Add binding for `dispass-remove-label'.
-rw-r--r-- | dispass.el | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -121,6 +121,7 @@ (set-keymap-parent map tabulated-list-mode-map) (define-key map "c" 'dispass-create) (define-key map "a" 'dispass-add-label) + (define-key map "d" 'dispass-remove-label) map)) (defun dispass-process-sentinel (proc status) @@ -203,6 +204,23 @@ an eye out for LABEL." (when (eq major-mode 'dispass-labels-mode) (revert-buffer))) +(defun dispass-remove-label (&optional label) + (interactive) + (let* ((labels-mode-p (eq major-mode 'dispass-labels-mode)) + (label (or label (when labels-mode-p (tabulated-list-get-id))))) + (unless label + (error + "LABEL required or must be called from `dispass-labels-mode'.")) + + (with-temp-buffer + (insert-file-contents dispass-file) + (re-search-forward (concat "^" label)) + (kill-whole-line) + (write-file dispass-file)) + + (when labels-mode-p + (revert-buffer)))) + (defun dispass-from-button (button) "Call dispass with information from BUTTON." (dispass (button-get button 'dispass-label) |