From 95b352802974f2866bb44f23112c42f830910290 Mon Sep 17 00:00:00 2001 From: ueno Date: Sun, 31 Dec 2006 04:07:41 +0000 Subject: [PATCH] * epa.el (epa--derived-mode-p): New alias. (epa-sign): Use it. (epa-encrypt): Use it. --- ChangeLog | 6 ++++++ epa.el | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7d3b2d..88b5e2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2006-12-31 Daiki Ueno + * epa.el (epa--derived-mode-p): New alias. + (epa-sign): Use it. + (epa-encrypt): Use it. + +2006-12-31 Daiki Ueno + * epa.el (epa--read-signature-type): New function. (epa-decrypt): New command. (epa-verify): New command. diff --git a/epa.el b/epa.el index 22d8bef..3e04508 100644 --- a/epa.el +++ b/epa.el @@ -908,6 +908,16 @@ If no one is selected, default secret key is used. " 'start-open t 'end-open t))))) +(if (fboundp 'derived-mode-p) + (defalias 'epa--derived-mode-p 'derived-mode-p) + (defun epa--derived-mode-p (&rest modes) + "Non-nil if the current major mode is derived from one of MODES. +Uses the `derived-mode-parent' property of the symbol to trace backwards." + (let ((parent major-mode)) + (while (and (not (memq parent modes)) + (setq parent (get parent 'derived-mode-parent)))) + parent))) + ;;;###autoload (defun epa-sign (start end signers mode) "Sign the current buffer. @@ -916,8 +926,7 @@ Don't use this command in Lisp programs!" (interactive (save-excursion (goto-char (point-min)) - (if (and (or (eq major-mode 'mail-mode) - (eq (derived-mode-class major-mode) 'mail-mode)) + (if (and (epa--derived-mode-p 'mail-mode) (search-forward mail-header-separator nil t)) (forward-line)) (setq epa-last-coding-system-specified @@ -988,8 +997,7 @@ Don't use this command in Lisp programs!" (save-excursion (let (recipients) (goto-char (point-min)) - (when (or (eq major-mode 'mail-mode) - (eq (derived-mode-class major-mode) 'mail-mode)) + (when (epa--derived-mode-p 'mail-mode) (save-restriction (narrow-to-region (point) (progn -- 1.7.10.4