summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2013-09-06 11:37:01 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2013-09-06 11:37:01 -0400
commit86cf73299170efd02eb9ede42547eca65df83c86 (patch)
tree87ee6c388fd4772b2301665d99af9a57282f70b5 /lisp
parent816244a2ab34d651371bf8045eac14320587beda (diff)
downloademacs-86cf73299170efd02eb9ede42547eca65df83c86.tar.gz
* lisp/abbrev.el (edit-abbrevs-mode): Use define-derived-mode.
(edit-abbrevs-mode-map): Rename from edit-abbrevs-map. * lisp/epa.el (epa--encode-coding-string, epa--decode-coding-string) (epa--select-safe-coding-system, epa--derived-mode-p): Make it obvious that it's defined. (epa-key-list-mode, epa-key-mode, epa-info-mode): Use define-derived-mode. * lisp/epg.el (epg-start-encrypt): Minor CSE simplification.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/abbrev.el19
-rw-r--r--lisp/epa.el71
-rw-r--r--lisp/epg.el5
4 files changed, 48 insertions, 60 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3c1a97b34b9..53335cb6311 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,16 @@
+2013-09-06 Stefan Monnier <monnier@iro.umontreal.ca>
+
+ * abbrev.el (edit-abbrevs-mode-map): Rename from edit-abbrevs-map.
+ (edit-abbrevs-mode): Use define-derived-mode.
+
+ * epa.el (epa--encode-coding-string, epa--decode-coding-string)
+ (epa--select-safe-coding-system, epa--derived-mode-p): Make it obvious
+ that it's defined.
+ (epa-key-list-mode, epa-key-mode, epa-info-mode):
+ Use define-derived-mode.
+
+ * epg.el (epg-start-encrypt): Minor CSE simplification.
+
2013-09-06 William Xu <william.xwl@gmail.com>
* arc-mode.el: Add support for 7za (bug#15264).
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index d82e2eabd84..d7d4482693d 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -67,13 +67,15 @@ be replaced by its expansion."
(put 'abbrev-mode 'safe-local-variable 'booleanp)
-(defvar edit-abbrevs-map
+(defvar edit-abbrevs-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-x\C-s" 'abbrev-edit-save-buffer)
(define-key map "\C-x\C-w" 'abbrev-edit-save-to-file)
(define-key map "\C-c\C-c" 'edit-abbrevs-redefine)
map)
"Keymap used in `edit-abbrevs'.")
+(define-obsolete-variable-alias 'edit-abbrevs-map
+ 'edit-abbrevs-mode-map "24.4")
(defun kill-all-abbrevs ()
"Undefine all defined abbrevs."
@@ -144,16 +146,6 @@ Otherwise display all abbrevs."
(set-buffer-modified-p nil)
(current-buffer))))
-(defun edit-abbrevs-mode ()
- "Major mode for editing the list of abbrev definitions.
-\\{edit-abbrevs-map}"
- (interactive)
- (kill-all-local-variables)
- (setq major-mode 'edit-abbrevs-mode)
- (setq mode-name "Edit-Abbrevs")
- (use-local-map edit-abbrevs-map)
- (run-mode-hooks 'edit-abbrevs-mode-hook))
-
(defun edit-abbrevs ()
"Alter abbrev definitions by editing a list of them.
Selects a buffer containing a list of abbrev definitions with
@@ -1013,6 +1005,11 @@ SORTFUN is passed to `sort' to change the default ordering."
(sort entries (lambda (x y)
(funcall sortfun (nth 2 x) (nth 2 y)))))))
+;; Keep it after define-abbrev-table, since define-derived-mode uses
+;; define-abbrev-table.
+(define-derived-mode edit-abbrevs-mode special-mode "Edit-Abbrevs"
+ "Major mode for editing the list of abbrev definitions.")
+
(provide 'abbrev)
;;; abbrev.el ends here
diff --git a/lisp/epa.el b/lisp/epa.el
index a99fb9230e1..1b06e6ca3bf 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -268,62 +268,40 @@ You should bind this variable with `let', but do not set it globally.")
(epg-sub-key-id (car (epg-key-sub-key-list
(widget-get widget :value))))))
-(eval-and-compile
- (if (fboundp 'encode-coding-string)
- (defalias 'epa--encode-coding-string 'encode-coding-string)
- (defalias 'epa--encode-coding-string 'identity)))
+(defalias 'epa--encode-coding-string
+ (if (fboundp 'encode-coding-string) #'encode-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)))
+(defalias 'epa--decode-coding-string
+ (if (fboundp 'decode-coding-string) #'decode-coding-string #'identity))
-(defun epa-key-list-mode ()
+(define-derived-mode epa-key-list-mode special-mode "Keys"
"Major mode for `epa-list-keys'."
- (kill-all-local-variables)
(buffer-disable-undo)
- (setq major-mode 'epa-key-list-mode
- mode-name "Keys"
- truncate-lines t
+ (setq truncate-lines t
buffer-read-only t)
- (use-local-map epa-key-list-mode-map)
- (make-local-variable 'font-lock-defaults)
- (setq font-lock-defaults '(epa-font-lock-keywords t))
+ (setq-local font-lock-defaults '(epa-font-lock-keywords t))
;; In XEmacs, auto-initialization of font-lock is not effective
;; if buffer-file-name is not set.
(font-lock-set-defaults)
(make-local-variable 'epa-exit-buffer-function)
- (make-local-variable 'revert-buffer-function)
- (setq revert-buffer-function 'epa--key-list-revert-buffer)
- (run-mode-hooks 'epa-key-list-mode-hook))
+ (setq-local revert-buffer-function #'epa--key-list-revert-buffer))
-(defun epa-key-mode ()
+(define-derived-mode epa-key-mode special-mode "Key"
"Major mode for a key description."
- (kill-all-local-variables)
(buffer-disable-undo)
- (setq major-mode 'epa-key-mode
- mode-name "Key"
- truncate-lines t
+ (setq truncate-lines t
buffer-read-only t)
- (use-local-map epa-key-mode-map)
- (make-local-variable 'font-lock-defaults)
- (setq font-lock-defaults '(epa-font-lock-keywords t))
+ (setq-local font-lock-defaults '(epa-font-lock-keywords t))
;; In XEmacs, auto-initialization of font-lock is not effective
;; if buffer-file-name is not set.
(font-lock-set-defaults)
- (make-local-variable 'epa-exit-buffer-function)
- (run-mode-hooks 'epa-key-mode-hook))
+ (make-local-variable 'epa-exit-buffer-function))
-(defun epa-info-mode ()
+(define-derived-mode epa-info-mode special-mode "Info"
"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-mode-hooks 'epa-info-mode-hook))
+ (setq truncate-lines t
+ buffer-read-only t))
(defun epa-mark-key (&optional arg)
"Mark a key on the current line.
@@ -951,10 +929,10 @@ See the reason described in the `epa-verify-region' documentation."
(error "No cleartext tail"))
(epa-verify-region cleartext-start cleartext-end))))))
-(eval-and-compile
+(defalias 'epa--select-safe-coding-system
(if (fboundp 'select-safe-coding-system)
- (defalias 'epa--select-safe-coding-system 'select-safe-coding-system)
- (defun epa--select-safe-coding-system (_from _to)
+ #'select-safe-coding-system
+ (lambda (_from _to)
buffer-file-coding-system)))
;;;###autoload
@@ -1026,16 +1004,16 @@ If no one is selected, default secret key is used. "
'start-open t
'end-open t)))))
-(eval-and-compile
+(defalias 'epa--derived-mode-p
(if (fboundp 'derived-mode-p)
- (defalias 'epa--derived-mode-p 'derived-mode-p)
- (defun epa--derived-mode-p (&rest modes)
+ #'derived-mode-p
+ (lambda (&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))))
+ (while (and (not (memq parent modes))
+ (setq parent (get parent 'derived-mode-parent))))
+ parent))))
;;;###autoload
(defun epa-encrypt-region (start end recipients sign signers)
@@ -1138,6 +1116,7 @@ If no one is selected, symmetric encryption will be performed. ")
(if (epg-context-result-for context 'import)
(epa-display-info (epg-import-result-to-string
(epg-context-result-for context 'import))))
+ ;; FIXME: Why not use the (otherwise unused) epa--derived-mode-p?
(if (eq major-mode 'epa-key-list-mode)
(apply #'epa--list-keys epa-list-keys-arguments))))
diff --git a/lisp/epg.el b/lisp/epg.el
index bcd91d8abba..c733a273988 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -2415,9 +2415,8 @@ If you are unsure, use synchronous version of this function
(list "--" (epg-data-file plain)))))
;; `gpgsm' does not read passphrase from stdin, so waiting is not needed.
(unless (eq (epg-context-protocol context) 'CMS)
- (if sign
- (epg-wait-for-status context '("BEGIN_SIGNING"))
- (epg-wait-for-status context '("BEGIN_ENCRYPTION"))))
+ (epg-wait-for-status context
+ (if sign '("BEGIN_SIGNING") '("BEGIN_ENCRYPTION"))))
(when (epg-data-string plain)
(if (eq (process-status (epg-context-process context)) 'run)
(process-send-string (epg-context-process context)