From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daiki Ueno Newsgroups: gmane.emacs.devel Subject: update of the EasyPG integration patch (Re: minor fixes for EasyPG Date: Fri, 18 Apr 2008 16:49:21 +0900 Message-ID: <87r6d338n2.fsf_-_@broken.deisui.org> References: <877ifjd24v.fsf@broken.deisui.org> <87r6dqywer.fsf@grepfind.mwolson.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1208505005 1221 80.91.229.12 (18 Apr 2008 07:50:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Apr 2008 07:50:05 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 18 09:50:38 2008 connect(): Connection refused Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JmlMg-00083d-RA for ged-emacs-devel@m.gmane.org; Fri, 18 Apr 2008 09:50:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmlM1-0001OU-JM for ged-emacs-devel@m.gmane.org; Fri, 18 Apr 2008 03:49:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JmlLn-0001IZ-4A for emacs-devel@gnu.org; Fri, 18 Apr 2008 03:49:39 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JmlLl-0001Hq-A7 for emacs-devel@gnu.org; Fri, 18 Apr 2008 03:49:38 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmlLl-0001Hj-45 for emacs-devel@gnu.org; Fri, 18 Apr 2008 03:49:37 -0400 Original-Received: from yw-out-1718.google.com ([74.125.46.153]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JmlLk-0001id-Q8 for emacs-devel@gnu.org; Fri, 18 Apr 2008 03:49:37 -0400 Original-Received: by yw-out-1718.google.com with SMTP id 9so699270ywk.66 for ; Fri, 18 Apr 2008 00:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:references:date:in-reply-to:message-id:user-agent:mime-version:content-type:sender; bh=DdN3GxO2+qtWvjAN2wqrbNaoehsYhNc3YvXlyGUdt7w=; b=rWuysoKYlYVFU0XLsH7lBGg2pT0mXRAbPyPSKAqD0QbJ4B3wfQkmdGHiFnwBUEEb7l8AiVXNN8YTEbz6s3zpwqE2fVqNQrlm0y3VI78ZiYyA9nGTThoBMtYOd+lon+J4Yr7dKtuudW9372v7XHcl/VATuZTctKRSdFnOPw3CtlU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:references:date:in-reply-to:message-id:user-agent:mime-version:content-type:sender; b=tNWmkeggPtlQaDXo4r1GuN/6nbZXtdh094u5fJxQhiSA4dRete+zdZk3jG/29fPwHRBDCyOJG7WJ9r89ToiqRN6gSQ5iyhgigtDrVWsBd6yuFNt3OzlJB3fnK0cyNDKnTf3ABj3gezTxlqqsbLBTe8V7kc/ntDR8AOSJFMpC51c= Original-Received: by 10.150.215.16 with SMTP id n16mr3182397ybg.16.1208504967911; Fri, 18 Apr 2008 00:49:27 -0700 (PDT) Original-Received: from p360 ( [150.82.173.253]) by mx.google.com with ESMTPS id 35sm3333167wra.37.2008.04.18.00.49.24 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 18 Apr 2008 00:49:26 -0700 (PDT) In-Reply-To: <87r6dqywer.fsf@grepfind.mwolson.org> (Michael Olson's message of "Mon, 31 Mar 2008 22:30:20 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:95425 Archived-At: --=-=-= >>>>> In <87r6dqywer.fsf@grepfind.mwolson.org> >>>>> Michael Olson wrote: > Daiki Ueno writes: > > Would someone please apply the attached patch which only contains > > minor bug/doc fixes for EasyPG? Then I'll post an update of the > > patch: http://article.gmane.org/gmane.emacs.devel/89452 Sorry for the delay. Please find the patch below, which I think ready to be installed into the trunk. Here are responses to the comments for the previous patch: >>>>> In >>>>> Richard Stallman wrote: > All this sounds good, but it might be desirable for Auto Encryption mode > to ask for confirmation before it decrypts any newly visited file for > the first time. It looks hard for me to do that, since I couldn't find an easy way to ask before find-file, and to inhibit file-name-handler per file. Do you have any idea? >>>>> In <200802181951.m1IJpGsN016364@sallyv1.ics.uci.edu> >>>>> Dan Nicolaescu wrote: > > + (when auto-encryption-mode (auto-encryption-mode 1)) > Turning on a mode when loading a file does not seem like not a good idea. > Instead, you could add a custom-reevaluate-setting call in startup.el Yes, I simply dropped the above line. Because it turned out that just setting :init-value of define-minor-mode runs the body of auto-encryption-mode as expected. 2008-04-18 Daiki Ueno * epa-file.el (auto-encryption-mode): Rename from epa-file-mode. (epa-file-handler): Put 'safe-magic and 'operations properties. * epa.el (epa-global-minor-modes): Abolish. (epa-mode): Abolish. (epa-menu): Abolish. (epa-menu-items): Abolish. * epa-dired.el (epa-dired-do-decrypt): Add autoload cookie. (epa-dired-do-verify): Ditto. (epa-dired-do-sign): Ditto. (epa-dired-do-encrypt): Ditto. (epa-dired-mode): Abolish. (epa-global-dired-mode): Abolish. * dired.el (dired-mode-map): Bind encryption/decryption commands. * menu-bar.el (menu-bar-encryption-decryption-menu): New menu item. * files.el (insert-file-contents-literally): Inhibit epa-file-handler. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=epg-integrate.diff diff --git a/lisp/dired.el b/lisp/dired.el index 375894c..521b176 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1279,6 +1279,11 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (define-key map "\C-tf" 'image-dired-mark-tagged-files) (define-key map "\C-t\C-t" 'image-dired-dired-insert-marked-thumbs) (define-key map "\C-te" 'image-dired-dired-edit-comment-and-tags) + ;; encryption and decryption (epa-dired) + (define-key map ":d" 'epa-dired-do-decrypt) + (define-key map ":v" 'epa-dired-do-verify) + (define-key map ":s" 'epa-dired-do-sign) + (define-key map ":e" 'epa-dired-do-encrypt) ;; Make menu bar items. @@ -1325,6 +1330,29 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST." (cons "Immediate" (make-sparse-keymap "Immediate"))) (define-key map + [menu-bar immediate epa-dired-do-decrypt] + '(menu-item "Decrypt" epa-dired-do-decrypt + :help "Decrypt file at cursor")) + + (define-key map + [menu-bar immediate epa-dired-do-verify] + '(menu-item "Verify" epa-dired-do-verify + :help "Verify digital signature of file at cursor")) + + (define-key map + [menu-bar immediate epa-dired-do-sign] + '(menu-item "Sign" epa-dired-do-sign + :help "Create digital signature of file at cursor")) + + (define-key map + [menu-bar immediate epa-dired-do-encrypt] + '(menu-item "Encrypt" epa-dired-do-encrypt + :help "Encrypt file at cursor")) + + (define-key map [menu-bar immediate dashes-4] + '("--")) + + (define-key map [menu-bar immediate image-dired-dired-display-external] '(menu-item "Display Image Externally" image-dired-dired-display-external :help "Display image in external viewer")) diff --git a/lisp/epa-dired.el b/lisp/epa-dired.el index a02081b..0a72c01 100644 --- a/lisp/epa-dired.el +++ b/lisp/epa-dired.el @@ -26,23 +26,7 @@ (require 'epa) (require 'dired) -(defvar epa-dired-mode-map - (let ((keymap (make-sparse-keymap))) - (define-key keymap ":d" 'epa-dired-do-decrypt) - (define-key keymap ":v" 'epa-dired-do-verify) - (define-key keymap ":s" 'epa-dired-do-sign) - (define-key keymap ":e" 'epa-dired-do-encrypt) - keymap)) - -(defvar epa-dired-mode-hook nil) -(defvar epa-dired-mode-on-hook nil) -(defvar epa-dired-mode-off-hook nil) - ;;;###autoload -(define-minor-mode epa-dired-mode - "A minor-mode for encrypt/decrypt files with Dired." - nil " epa-dired" epa-dired-mode-map) - (defun epa-dired-do-decrypt () "Decrypt marked files." (interactive) @@ -52,6 +36,7 @@ (setq file-list (cdr file-list))) (revert-buffer))) +;;;###autoload (defun epa-dired-do-verify () "Verify marked files." (interactive) @@ -60,6 +45,7 @@ (epa-verify-file (expand-file-name (car file-list))) (setq file-list (cdr file-list))))) +;;;###autoload (defun epa-dired-do-sign () "Sign marked files." (interactive) @@ -74,6 +60,7 @@ If no one is selected, default secret key is used. " (setq file-list (cdr file-list))) (revert-buffer))) +;;;###autoload (defun epa-dired-do-encrypt () "Encrypt marked files." (interactive) @@ -86,14 +73,6 @@ If no one is selected, symmetric encryption will be performed. ")) (setq file-list (cdr file-list))) (revert-buffer))) -;;;###autoload -(define-minor-mode epa-global-dired-mode - "Minor mode to hook EasyPG into Dired." - :global t :init-value nil :group 'epa-dired :version "23.1" - (remove-hook 'dired-mode-hook 'epa-dired-mode) - (if epa-global-dired-mode - (add-hook 'dired-mode-hook 'epa-dired-mode))) - (provide 'epa-dired) ;; arch-tag: 2025700b-48d0-4684-bc94-228ad1f8e9ff diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 5580484..7d53b87 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -126,7 +126,10 @@ May either be a string or a list of strings.") (defun epa-file-handler (operation &rest args) (save-match-data (let ((op (get operation 'epa-file))) - (if op + (if (and op + (if (and (eq operation 'insert-file-contents) + + (y-or-n-p "" (apply op args) (epa-file-run-real-handler operation args))))) @@ -300,7 +303,7 @@ If no one is selected, symmetric encryption will be performed. ")))) (message "`epa-file' already enabled") (setq file-name-handler-alist (cons epa-file-handler file-name-handler-alist)) - (add-hook 'find-file-hooks 'epa-file-find-file-hook) + (add-hook 'find-file-hook 'epa-file-find-file-hook) (setq auto-mode-alist (cons epa-file-auto-mode-alist-entry auto-mode-alist)) (message "`epa-file' enabled"))) @@ -311,30 +314,35 @@ If no one is selected, symmetric encryption will be performed. ")))) (progn (setq file-name-handler-alist (delq epa-file-handler file-name-handler-alist)) - (remove-hook 'find-file-hooks 'epa-file-find-file-hook) + (remove-hook 'find-file-hook 'epa-file-find-file-hook) (setq auto-mode-alist (delq epa-file-auto-mode-alist-entry auto-mode-alist)) (message "`epa-file' disabled")) (message "`epa-file' already disabled"))) ;;;###autoload -(define-minor-mode epa-file-mode +(define-minor-mode auto-encryption-mode "Toggle automatic file encryption and decryption. With prefix argument ARG, turn auto encryption on if positive, else off. Return the new status of auto encryption (non-nil means on)." - :global t :init-value nil :group 'epa-file :version "23.1" + :global t :init-value t :group 'epa-file :version "23.1" (setq file-name-handler-alist (delq epa-file-handler file-name-handler-alist)) (remove-hook 'find-file-hooks 'epa-file-find-file-hook) (setq auto-mode-alist (delq epa-file-auto-mode-alist-entry auto-mode-alist)) - (when epa-file-mode + (when auto-encryption-mode (setq file-name-handler-alist (cons epa-file-handler file-name-handler-alist)) - (add-hook 'find-file-hooks 'epa-file-find-file-hook) + (add-hook 'find-file-hook 'epa-file-find-file-hook) + (add-hook 'find-file-not-found-functions + 'epa-file-find-file-not-found-functions) (setq auto-mode-alist (cons epa-file-auto-mode-alist-entry auto-mode-alist)))) +(put 'epa-file-handler 'safe-magic t) +(put 'epa-file-handler 'operations '(write-region insert-file-contents)) + (provide 'epa-file) ;; arch-tag: 5715152f-0eb1-4dbc-9008-07098775314d diff --git a/lisp/epa.el b/lisp/epa.el index 4f2b743..2e2630b 100644 --- a/lisp/epa.el +++ b/lisp/epa.el @@ -45,13 +45,6 @@ the separate window." :type 'integer :group 'epa) -(defcustom epa-global-minor-modes '(epa-global-dired-mode - epa-global-mail-mode - epa-file-mode) - "Globally defined minor modes to hook into other modes." - :type '(repeat symbol) - :group 'epa) - (defgroup epa-faces nil "Faces for epa-mode." :version "23.1" @@ -236,44 +229,6 @@ You should bind this variable with `let', but do not set it globally.") (define-key keymap "q" 'delete-window) keymap)) -(defvar epa-menu nil) - -(defconst epa-menu-items - '("Encryption/Decryption" - ("Decrypt" - ["File" epa-decrypt-file - :help "Decrypt a file"] - ["Region" epa-decrypt-region - :help "Decrypt the current region"]) - ("Verify" - ["File" epa-verify-file - :help "Verify digital signature of a file"] - ["Region" epa-verify-region - :help "Verify digital signature of the current region"]) - ("Sign" - ["File" epa-sign-file - :help "Create digital signature of a file"] - ["Region" epa-sign-region - :help "Create digital signature of the current region"]) - ("Encrypt" - ["File" epa-encrypt-file - :help "Encrypt a file"] - ["Region" epa-encrypt-region - :help "Encrypt the current region"]) - "----" - ["Browse keyring" epa-list-keys - :help "Browse your public keyring"] - ("Import keys" - ["File" epa-import-keys - :help "Import public keys from a file"] - ["Region" epa-import-keys-region - :help "Import public keys from the current region"]) - ("Export key" - ["To a File" epa-export-keys - :help "Export public keys to a file"] - ["To a Buffer" epa-insert-keys - :help "Insert public keys after the current point"]))) - (defvar epa-exit-buffer-function #'bury-buffer) (define-widget 'epa-key 'push-button @@ -1257,27 +1212,6 @@ between START and END." ;; (message "Signing keys...done"))) ;; (make-obsolete 'epa-sign-keys "Do not use.") -;;;###autoload -(define-minor-mode epa-mode - "Minor mode to hook EasyPG into various modes. -See `epa-global-minor-modes'." - :global t :init-value nil :group 'epa :version "23.1" - (unless epa-menu - (easy-menu-define epa-menu nil "EasyPG Assistant global menu" - epa-menu-items)) - (easy-menu-remove-item nil '("Tools") "Encryption/Decryption") - (if epa-mode - (easy-menu-add-item nil '("Tools") epa-menu)) - (let ((modes epa-global-minor-modes) - symbol) - (while modes - (setq symbol (car modes)) - (if (and symbol - (fboundp symbol)) - (funcall symbol epa-mode) - (message "`%S' not found" (car modes))) - (setq modes (cdr modes))))) - (provide 'epa) ;; arch-tag: 38d20ced-20d5-4137-b17a-f206335423d7 diff --git a/lisp/files.el b/lisp/files.el index 07b8a06..2699946 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1784,7 +1784,7 @@ This function ensures that none of these modifications will take place." (symbol-function 'find-buffer-file-type) nil)) (inhibit-file-name-handlers - (append '(jka-compr-handler image-file-handler) + (append '(jka-compr-handler image-file-handler epa-file-handler) inhibit-file-name-handlers)) (inhibit-file-name-operation 'insert-file-contents)) (unwind-protect diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 00f7678..8246e64 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -1093,6 +1093,70 @@ mail status in mode line")) (known (assq read-mail-command known-rmail-commands))) (if known (cdr known) (symbol-name read-mail-command)))) +(defvar menu-bar-encryption-decryption-menu + (make-sparse-keymap "Encryption/Decryption")) + +(define-key menu-bar-tools-menu [encryption-decryption] + (list 'menu-item "Encryption/Decryption" menu-bar-encryption-decryption-menu)) + +(define-key menu-bar-tools-menu [separator-encryption-decryption] + '("--")) + +(define-key menu-bar-encryption-decryption-menu [insert-keys] + '(menu-item "Insert Keys" epa-insert-keys + :help "Insert public keys after the current point")) + +(define-key menu-bar-encryption-decryption-menu [export-keys] + '(menu-item "Export Keys" epa-export-keys + :help "Export public keys to a file")) + +(define-key menu-bar-encryption-decryption-menu [import-keys-region] + '(menu-item "Import Keys from Region" epa-import-keys-region + :help "Import public keys from the current region")) + +(define-key menu-bar-encryption-decryption-menu [import-keys] + '(menu-item "Import Keys from File" epa-import-keys + :help "Import public keys from a file")) + +(define-key menu-bar-encryption-decryption-menu [list-keys] + '(menu-item "List Keys" epa-list-keys + :help "Browse your public keyring")) + +(define-key menu-bar-encryption-decryption-menu [separator-keys] + '("--")) + +(define-key menu-bar-encryption-decryption-menu [encrypt-region] + '(menu-item "Encrypt Region" epa-encrypt-region + :help "Encrypt the current region")) + +(define-key menu-bar-encryption-decryption-menu [encrypt-file] + '(menu-item "Encrypt File" epa-encrypt-file + :help "Encrypt a file")) + +(define-key menu-bar-encryption-decryption-menu [sign-region] + '(menu-item "Sign Region" epa-sign-region + :help "Create digital signature of the current region")) + +(define-key menu-bar-encryption-decryption-menu [sign-file] + '(menu-item "Sign File" epa-sign-file + :help "Create digital signature of a file")) + +(define-key menu-bar-encryption-decryption-menu [verify-region] + '(menu-item "Verify Region" epa-verify-region + :help "Verify digital signature of the current region")) + +(define-key menu-bar-encryption-decryption-menu [verify-file] + '(menu-item "Verify File" epa-verify-file + :help "Verify digital signature of a file")) + +(define-key menu-bar-encryption-decryption-menu [decrypt-region] + '(menu-item "Decrypt Region" epa-decrypt-region + :help "Decrypt the current region")) + +(define-key menu-bar-encryption-decryption-menu [decrypt-file] + '(menu-item "Decrypt File" epa-decrypt-file + :help "Decrypt a file")) + (defvar menu-bar-games-menu (make-sparse-keymap "Games")) (define-key menu-bar-tools-menu [games] --=-=-= Regards, -- Daiki Ueno --=-=-=--