"Faces for epa-mode."
:group 'epa)
-(defface epa-validity-high-face
- '((((class color) (background dark))
- (:foreground "PaleTurquoise" :bold t))
+(defface epa-validity-high
+ `((((class color) (background dark))
+ (:foreground "PaleTurquoise"
+ ,@(if (assq ':weight custom-face-attributes)
+ '(:weight bold)
+ '(:bold t))))
(t
- (:bold t)))
+ ,@(if (assq ':weight custom-face-attributes)
+ '(:weight bold)
+ '(:bold t))))
"Face used for displaying the high validity."
:group 'epa-faces)
-(defvar epa-validity-high-face 'epa-validity-high-face)
-(defface epa-validity-medium-face
- '((((class color) (background dark))
- (:foreground "PaleTurquoise" :italic t))
+(defface epa-validity-medium
+ `((((class color) (background dark))
+ (:foreground "PaleTurquoise"
+ ,@(if (assq ':slant custom-face-attributes)
+ '(:slant italic)
+ '(:italic t))))
(t
- ()))
+ (,@(if (assq ':slant custom-face-attributes)
+ '(:slant italic)
+ '(:italic t)))))
"Face used for displaying the medium validity."
:group 'epa-faces)
-(defvar epa-validity-medium-face 'epa-validity-medium-face)
-(defface epa-validity-low-face
- '((t
- (:italic t)))
+(defface epa-validity-low
+ `((t
+ (,@(if (assq ':slant custom-face-attributes)
+ '(:slant italic)
+ '(:italic t)))))
"Face used for displaying the low validity."
:group 'epa-faces)
-(defvar epa-validity-low-face 'epa-validity-low-face)
-(defface epa-validity-disabled-face
- '((t
- (:italic t :inverse-video t)))
+(defface epa-validity-disabled
+ `((t
+ (,@(if (assq ':slant custom-face-attributes)
+ '(:slant italic)
+ '(:italic t))
+ :inverse-video t)))
"Face used for displaying the disabled validity."
:group 'epa-faces)
-(defvar epa-validity-disabled-face 'epa-validity-disabled-face)
-(defface epa-string-face
- '((((class color)
- (background dark))
+(defface epa-string
+ '((((class color) (background dark))
(:foreground "lightyellow"))
- (((class color)
- (background light))
- (:foreground "blue4"))
- (t
- ()))
+ (((class color) (background light))
+ (:foreground "blue4")))
"Face used for displaying the string."
:group 'epa-faces)
-(defvar epa-string-face 'epa-string-face)
-(defface epa-mark-face
- '((((class color) (background dark))
- (:foreground "orange" :bold t))
+(defface epa-mark
+ `((((class color) (background dark))
+ (:foreground "orange"
+ ,@(if (assq ':weight custom-face-attributes)
+ '(:weight bold)
+ '(:bold t))))
+ (((class color) (background light))
+ (:foreground "red"
+ ,@(if (assq ':weight custom-face-attributes)
+ '(:weight bold)
+ '(:bold t))))
(t
- (:foreground "red" :bold t)))
+ (,@(if (assq ':weight custom-face-attributes)
+ '(:weight bold)
+ '(:bold t)))))
"Face used for displaying the high validity."
:group 'epa-faces)
-(defvar epa-mark-face 'epa-mark-face)
-(defface epa-field-name-face
- '((((class color) (background dark))
- (:foreground "PaleTurquoise" :bold t))
- (t (:bold t)))
+(defface epa-field-name
+ `((((class color) (background dark))
+ (:foreground "PaleTurquoise"
+ ,@(if (assq ':weight custom-face-attributes)
+ '(:weight bold)
+ '(:bold t))))
+ (t
+ (,@(if (assq ':weight custom-face-attributes)
+ '(:weight bold)
+ '(:bold t)))))
"Face for the name of the attribute field."
:group 'epa)
-(defvar epa-field-name-face 'epa-field-name-face)
-(defface epa-field-body-face
- '((((class color) (background dark))
- (:foreground "turquoise" :italic t))
- (t (:italic t)))
+(defface epa-field-body
+ `((((class color) (background dark))
+ (:foreground "turquoise"
+ ,@(if (assq ':slant custom-face-attributes)
+ '(:slant italic)
+ '(:italic t))))
+ (t
+ (,@(if (assq ':slant custom-face-attributes)
+ '(:slant italic)
+ '(:italic t)))))
"Face for the body of the attribute field."
:group 'epa)
-(defvar epa-field-body-face 'epa-field-body-face)
(defcustom epa-validity-face-alist
- '((unknown . epa-validity-disabled-face)
- (invalid . epa-validity-disabled-face)
- (disabled . epa-validity-disabled-face)
- (revoked . epa-validity-disabled-face)
- (expired . epa-validity-disabled-face)
- (none . epa-validity-low-face)
- (undefined . epa-validity-low-face)
- (never . epa-validity-low-face)
- (marginal . epa-validity-medium-face)
- (full . epa-validity-high-face)
- (ultimate . epa-validity-high-face))
+ '((unknown . epa-validity-disabled)
+ (invalid . epa-validity-disabled)
+ (disabled . epa-validity-disabled)
+ (revoked . epa-validity-disabled)
+ (expired . epa-validity-disabled)
+ (none . epa-validity-low)
+ (undefined . epa-validity-low)
+ (never . epa-validity-low)
+ (marginal . epa-validity-medium)
+ (full . epa-validity-high)
+ (ultimate . epa-validity-high))
"An alist mapping validity values to faces."
:type 'list
:group 'epa)
(defcustom epa-font-lock-keywords
'(("^\\*"
- (0 epa-mark-face))
+ (0 'epa-mark))
("^\t\\([^\t:]+:\\)[ \t]*\\(.*\\)$"
- (1 epa-field-name-face)
- (2 epa-field-body-face)))
+ (1 'epa-field-name)
+ (2 'epa-field-body)))
"Default expressions to addon in epa-mode."
:type '(repeat (list string))
:group 'epa)
(defvar epa-key-list-mode-map
(let ((keymap (make-sparse-keymap)))
- (define-key keymap "m" 'epa-mark)
- (define-key keymap "u" 'epa-unmark)
+ (define-key keymap "m" 'epa-mark-key)
+ (define-key keymap "u" 'epa-unmark-key)
(define-key keymap "d" 'epa-decrypt-file)
(define-key keymap "v" 'epa-verify-file)
(define-key keymap "s" 'epa-sign-file)
(epg-sub-key-id (car (epg-key-sub-key-list
(widget-get widget :value))))))
-(if (fboundp 'encode-coding-string)
- (defalias 'epa--encode-coding-string 'encode-coding-string)
- (defalias 'epa--encode-coding-string 'identity))
+(eval-and-compile
+ (if (fboundp 'encode-coding-string)
+ (defalias 'epa--encode-coding-string 'encode-coding-string)
+ (defalias 'epa--encode-coding-string 'identity)))
-(if (fboundp 'decode-coding-string)
- (defalias 'epa--decode-coding-string 'decode-coding-string)
- (defalias 'epa--decode-coding-string 'identity))
+(eval-and-compile
+ (if (fboundp 'decode-coding-string)
+ (defalias 'epa--decode-coding-string 'decode-coding-string)
+ (defalias 'epa--decode-coding-string 'identity)))
(defun epa-key-list-mode ()
"Major mode for `epa-list-keys'."
(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."
+(defun epa-mark-key (&optional arg)
+ "Mark a key on the current line.
+If ARG is non-nil, unmark the key."
(interactive "P")
(let ((inhibit-read-only t)
buffer-read-only
properties)
(beginning-of-line)
+ (unless (get-text-property (point) 'epa-key)
+ (error "No key on this 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."
+(defun epa-unmark-key (&optional arg)
+ "Unmark a key on the current line.
+If ARG is non-nil, mark the key."
(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))) ?*)))
+ (epa-mark-key (not arg)))
(defun epa-exit-buffer ()
"Exit the current buffer.
(erase-buffer)
(insert prompt "\n"
(substitute-command-keys "\
-- `\\[epa-mark]' to mark a key on the line
-- `\\[epa-unmark]' to unmark a key on the line\n"))
+- `\\[epa-mark-key]' to mark a key on the line
+- `\\[epa-unmark-key]' to unmark a key on the line\n"))
(widget-create 'link
:notify (lambda (&rest ignore) (abort-recursive-edit))
:help-echo
(error "No cleartext tail"))
(epa-verify-region cleartext-start cleartext-end))))))
-(if (fboundp 'select-safe-coding-system)
- (defalias 'epa--select-safe-coding-system 'select-safe-coding-system)
- (defun epa--select-safe-coding-system (from to)
- buffer-file-coding-system))
+(eval-and-compile
+ (if (fboundp 'select-safe-coding-system)
+ (defalias 'epa--select-safe-coding-system 'select-safe-coding-system)
+ (defun epa--select-safe-coding-system (from to)
+ buffer-file-coding-system)))
;;;###autoload
(defun epa-sign-region (start end signers mode)
'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.
+(eval-and-compile
+ (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)))
+ (let ((parent major-mode))
+ (while (and (not (memq parent modes))
+ (setq parent (get parent 'derived-mode-parent))))
+ parent))))
;;;###autoload
(defun epa-encrypt-region (start end recipients sign signers)