From: ueno Date: Wed, 27 Sep 2006 05:57:29 +0000 (+0000) Subject: Rearrange functions. X-Git-Tag: epg-0_0_6~13 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18c24a4607ee47aa204806756a768c5cbd204b60;p=elisp%2Fepg.git Rearrange functions. --- diff --git a/epa.el b/epa.el index c95f0e1..cc87f52 100644 --- a/epa.el +++ b/epa.el @@ -273,6 +273,48 @@ the separate window." (make-local-variable 'epa-exit-buffer-function) (run-hooks 'epa-key-mode-hook)) +(defun epa-info-mode () + "Major mode for `epa-info-buffer'." + (kill-all-local-variables) + (buffer-disable-undo) + (setq major-mode 'epa-info-mode + mode-name "Info" + truncate-lines t + buffer-read-only t) + (use-local-map epa-info-mode-map) + (run-hooks 'epa-info-mode-hook)) + +(defun epa-mark (&optional arg) + "Mark the current line. +If ARG is non-nil, unmark the current line." + (interactive "P") + (let ((inhibit-read-only t) + buffer-read-only + properties) + (beginning-of-line) + (setq properties (text-properties-at (point))) + (delete-char 1) + (insert (if arg " " "*")) + (set-text-properties (1- (point)) (point) properties) + (forward-line))) + +(defun epa-unmark (&optional arg) + "Unmark the current line. +If ARG is non-nil, mark the current line." + (interactive "P") + (epa-mark (not arg))) + +(defun epa-toggle-mark () + "Toggle the mark the current line." + (interactive) + (epa-mark (eq (char-after (save-excursion (beginning-of-line) (point))) ?*))) + +(defun epa-exit-buffer () + "Exit the current buffer. +`epa-exit-buffer-function' is called if it is set." + (interactive) + (funcall epa-exit-buffer-function)) + ;;;###autoload (defun epa-list-keys (&optional name mode protocol) (interactive @@ -476,37 +518,6 @@ If SECRET is non-nil, list secret keys instead of public keys." (defun epa-show-key-notify (widget &rest ignore) (epa-show-key (widget-get widget :value))) -(defun epa-mark (&optional arg) - "Mark the current line. -If ARG is non-nil, unmark the current line." - (interactive "P") - (let ((inhibit-read-only t) - buffer-read-only - properties) - (beginning-of-line) - (setq properties (text-properties-at (point))) - (delete-char 1) - (insert (if arg " " "*")) - (set-text-properties (1- (point)) (point) properties) - (forward-line))) - -(defun epa-unmark (&optional arg) - "Unmark the current line. -If ARG is non-nil, mark the current line." - (interactive "P") - (epa-mark (not arg))) - -(defun epa-toggle-mark () - "Toggle the mark the current line." - (interactive) - (epa-mark (eq (char-after (save-excursion (beginning-of-line) (point))) ?*))) - -(defun epa-exit-buffer () - "Exit the current buffer. -`epa-exit-buffer-function' is called if it is set." - (interactive) - (funcall epa-exit-buffer-function)) - (defun epa-display-verify-result (verify-result) (if epa-popup-info-window (progn @@ -525,16 +536,23 @@ If ARG is non-nil, mark the current line." (goto-char (point-min))) (message "%s" (epg-verify-result-to-string verify-result)))) -(defun epa-info-mode () - "Major mode for `epa-info-buffer'." - (kill-all-local-variables) - (buffer-disable-undo) - (setq major-mode 'epa-info-mode - mode-name "Info" - truncate-lines t - buffer-read-only t) - (use-local-map epa-info-mode-map) - (run-hooks 'epa-info-mode-hook)) +(defun epa-passphrase-callback-function (context key-id handback) + (if (eq key-id 'SYM) + (read-passwd "Passphrase for symmetric encryption: " + (eq (epg-context-operation context) 'encrypt)) + (read-passwd + (if (eq key-id 'PIN) + "Passphrase for PIN: " + (let ((entry (assoc key-id epg-user-id-alist))) + (if entry + (format "Passphrase for %s %s: " key-id (cdr entry)) + (format "Passphrase for %s: " key-id))))))) + +(defun epa-progress-callback-function (context what char current total + handback) + (message "%s: %d%% (%d/%d)" what + (if (> total 0) (floor (* (/ current (float total)) 100)) 0) + current total)) ;;;###autoload (defun epa-decrypt-file (file) @@ -833,24 +851,6 @@ If LOCAL is non-nil, the signature is marked as non exportable." (epg-sign-keys context keys local) (message "Signing keys...done"))) -(defun epa-passphrase-callback-function (context key-id handback) - (if (eq key-id 'SYM) - (read-passwd "Passphrase for symmetric encryption: " - (eq (epg-context-operation context) 'encrypt)) - (read-passwd - (if (eq key-id 'PIN) - "Passphrase for PIN: " - (let ((entry (assoc key-id epg-user-id-alist))) - (if entry - (format "Passphrase for %s %s: " key-id (cdr entry)) - (format "Passphrase for %s: " key-id))))))) - -(defun epa-progress-callback-function (context what char current total - handback) - (message "%s: %d%% (%d/%d)" what - (if (> total 0) (floor (* (/ current (float total)) 100)) 0) - current total)) - (provide 'epa) ;;; epa.el ends here