Mercurial > emacs
annotate lisp/epa-mail.el @ 109581:06384b3caebf
Add ability to put Gtk+ tool bar on the left/right/bottom or top. Default top.
* lisp/menu-bar.el (menu-bar-showhide-tool-bar-menu-customize-enable-left)
(menu-bar-showhide-tool-bar-menu-customize-disable)
(menu-bar-showhide-tool-bar-menu-customize-enable-right)
(menu-bar-showhide-tool-bar-menu-customize-enable-top)
(menu-bar-showhide-tool-bar-menu-customize-enable-bottom): New functions
(menu-bar-showhide-tool-bar-menu): If tool bar is moveable,
make a menu for Options => toolbar that can move it.
* src/frame.c (Qtool_bar_position): New variable.
(make_frame): Set tool_bar_position to Qtop.
(frame_parms): Add tool-bar-position.
(x_report_frame_params): Store tool_bar_position.
(x_set_fringe_width): Reset wm size hint after fringe changes.
* src/frame.h (struct frame): Add tool_bar_position.
(Qbottom): Declare.
* src/gtkutil.c (FRAME_TOTAL_PIXEL_WIDTH): New macro.
(xg_frame_set_char_size): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
(xg_height_or_width_changed): Use FRAME_TOTAL_PIXEL_WIDTH.
(xg_create_frame_widgets): Create a hobox for placing widgets
vertically. Use gtk_box_pack_start.
(xg_height_or_width_changed): Renamed from xg_height_changed.
(x_wm_set_size_hint): Add FRAME_TOOLBAR_WIDTH to base_width.
(xg_update_frame_menubar, free_frame_menubar): Change to
xg_height_or_width_changed.
(xg_tool_bar_detach_callback): Update left/right/top/bottom tool bar
size correctly. Remove hardcoded 4, instead use handlebox size -
toolbar size.
(xg_tool_bar_attach_callback): Update left/right/top/bottom tool bar
size correctly. Use handlebox size + toolbar size as additional
size.
(xg_pack_tool_bar): POS is a new parameter.
Set orientation of tool bar based on pos.
Only make handlebox_widget if NULL.
Check if tool bar goes to vbox or hbox depending on pos.
(xg_update_tool_bar_sizes): New function.
(update_frame_tool_bar): Remove old_req, new_req. Do not get tool bar
height, call xg_update_tool_bar_sizes instead.
(free_frame_tool_bar): Remove from hbox or vbox depending on
toolbar_in_hbox, Set all FRAME_TOOLBAR_*_(WIDTH|HEIGHT) to zero.
(xg_change_toolbar_position): New function.
* src/gtkutil.h (xg_change_toolbar_position): Declare.
* src/window.c (calc_absolute_offset): Check for FRAME_TOOLBAR_TOP_HEIGHT
and FRAME_TOOLBAR_LEFT_WIDTH.
* src/xfns.c (x_set_tool_bar_position): New function.
(xic_set_statusarea): Use FRAME_TOOLBAR_TOP_HEIGHT.
(x_frame_parm_handlers): Add x_set_tool_bar_position.
(syms_of_xfns): if USE_GTK, provide move-toolbar.
* src/xterm.c (x_set_window_size_1): Add FRAME_TOOLBAR_WIDTH to pixelwidth.
* src/xterm.h (struct x_output): Add toolbar_top_height,
toolbar_bottom_height, toolbar_left_width, toolbar_right_width. Remove
toolbar_height.
if USE_GTK: Add hbox_widget and toolbar_in_hbox.
(FRAME_TOOLBAR_TOP_HEIGHT, FRAME_TOOLBAR_BOTTOM_HEIGHT)
(FRAME_TOOLBAR_LEFT_WIDTH, FRAME_TOOLBAR_RIGHT_WIDTH): New macros.
(FRAME_TOOLBAR_HEIGHT): Is now TOP_HEIGHT + BOTTOM_HEIGHT.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Thu, 29 Jul 2010 18:49:59 +0200 |
parents | 018487fd2873 |
children | 280c8ae2476d |
rev | line source |
---|---|
91647 | 1 ;;; epa-mail.el --- the EasyPG Assistant, minor-mode for mail composer |
106815 | 2 ;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
91647 | 3 |
4 ;; Author: Daiki Ueno <ueno@unixuser.org> | |
5 ;; Keywords: PGP, GnuPG, mail, message | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91733
diff
changeset
|
9 ;; GNU Emacs is free software: you can redistribute it and/or modify |
91647 | 10 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91733
diff
changeset
|
11 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91733
diff
changeset
|
12 ;; (at your option) any later version. |
91647 | 13 |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91733
diff
changeset
|
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
91647 | 21 |
22 ;;; Code: | |
23 | |
24 (require 'epa) | |
25 (require 'mail-utils) | |
26 | |
27 (defvar epa-mail-mode-map | |
28 (let ((keymap (make-sparse-keymap))) | |
29 (define-key keymap "\C-c\C-ed" 'epa-mail-decrypt) | |
30 (define-key keymap "\C-c\C-ev" 'epa-mail-verify) | |
31 (define-key keymap "\C-c\C-es" 'epa-mail-sign) | |
32 (define-key keymap "\C-c\C-ee" 'epa-mail-encrypt) | |
33 (define-key keymap "\C-c\C-ei" 'epa-mail-import-keys) | |
34 (define-key keymap "\C-c\C-eo" 'epa-insert-keys) | |
109546
018487fd2873
Add alternative key bindings to epa-mail.el.
Daiki Ueno <ueno@unixuser.org>
parents:
106815
diff
changeset
|
35 (define-key keymap "\C-c\C-e\C-d" 'epa-mail-decrypt) |
018487fd2873
Add alternative key bindings to epa-mail.el.
Daiki Ueno <ueno@unixuser.org>
parents:
106815
diff
changeset
|
36 (define-key keymap "\C-c\C-e\C-v" 'epa-mail-verify) |
018487fd2873
Add alternative key bindings to epa-mail.el.
Daiki Ueno <ueno@unixuser.org>
parents:
106815
diff
changeset
|
37 (define-key keymap "\C-c\C-e\C-s" 'epa-mail-sign) |
018487fd2873
Add alternative key bindings to epa-mail.el.
Daiki Ueno <ueno@unixuser.org>
parents:
106815
diff
changeset
|
38 (define-key keymap "\C-c\C-e\C-e" 'epa-mail-encrypt) |
018487fd2873
Add alternative key bindings to epa-mail.el.
Daiki Ueno <ueno@unixuser.org>
parents:
106815
diff
changeset
|
39 (define-key keymap "\C-c\C-e\C-i" 'epa-mail-import-keys) |
018487fd2873
Add alternative key bindings to epa-mail.el.
Daiki Ueno <ueno@unixuser.org>
parents:
106815
diff
changeset
|
40 (define-key keymap "\C-c\C-e\C-o" 'epa-insert-keys) |
91647 | 41 keymap)) |
42 | |
43 (defvar epa-mail-mode-hook nil) | |
44 (defvar epa-mail-mode-on-hook nil) | |
45 (defvar epa-mail-mode-off-hook nil) | |
46 | |
91731
7efbdc83b944
EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents:
91687
diff
changeset
|
47 ;;;###autoload |
91647 | 48 (define-minor-mode epa-mail-mode |
49 "A minor-mode for composing encrypted/clearsigned mails." | |
50 nil " epa-mail" epa-mail-mode-map) | |
51 | |
52 (defun epa-mail--find-usable-key (keys usage) | |
53 "Find a usable key from KEYS for USAGE." | |
54 (catch 'found | |
55 (while keys | |
56 (let ((pointer (epg-key-sub-key-list (car keys)))) | |
57 (while pointer | |
58 (if (and (memq usage (epg-sub-key-capability (car pointer))) | |
59 (not (memq (epg-sub-key-validity (car pointer)) | |
60 '(revoked expired)))) | |
61 (throw 'found (car keys))) | |
62 (setq pointer (cdr pointer)))) | |
63 (setq keys (cdr keys))))) | |
64 | |
65 ;;;###autoload | |
66 (defun epa-mail-decrypt () | |
67 "Decrypt OpenPGP armors in the current buffer. | |
68 The buffer is expected to contain a mail message. | |
69 | |
70 Don't use this command in Lisp programs!" | |
71 (interactive) | |
72 (epa-decrypt-armor-in-region (point-min) (point-max))) | |
73 | |
74 ;;;###autoload | |
75 (defun epa-mail-verify () | |
76 "Verify OpenPGP cleartext signed messages in the current buffer. | |
77 The buffer is expected to contain a mail message. | |
78 | |
79 Don't use this command in Lisp programs!" | |
80 (interactive) | |
81 (epa-verify-cleartext-in-region (point-min) (point-max))) | |
82 | |
83 ;;;###autoload | |
84 (defun epa-mail-sign (start end signers mode) | |
85 "Sign the current buffer. | |
86 The buffer is expected to contain a mail message. | |
87 | |
88 Don't use this command in Lisp programs!" | |
89 (interactive | |
90 (save-excursion | |
91 (goto-char (point-min)) | |
92 (if (search-forward mail-header-separator nil t) | |
93 (forward-line)) | |
94 (setq epa-last-coding-system-specified | |
95 (or coding-system-for-write | |
96 (epa--select-safe-coding-system (point) (point-max)))) | |
97 (let ((verbose current-prefix-arg)) | |
98 (list (point) (point-max) | |
99 (if verbose | |
100 (epa-select-keys (epg-make-context epa-protocol) | |
101 "Select keys for signing. | |
102 If no one is selected, default secret key is used. " | |
103 nil t)) | |
104 (if verbose | |
105 (epa--read-signature-type) | |
106 'clear))))) | |
107 (epa-sign-region start end signers mode)) | |
108 | |
109 ;;;###autoload | |
110 (defun epa-mail-encrypt (start end recipients sign signers) | |
111 "Encrypt the current buffer. | |
112 The buffer is expected to contain a mail message. | |
113 | |
114 Don't use this command in Lisp programs!" | |
115 (interactive | |
116 (save-excursion | |
117 (let ((verbose current-prefix-arg) | |
118 (context (epg-make-context epa-protocol)) | |
119 recipients recipient-key) | |
120 (goto-char (point-min)) | |
121 (save-restriction | |
122 (narrow-to-region (point) | |
123 (if (search-forward mail-header-separator nil 0) | |
124 (match-beginning 0) | |
125 (point))) | |
126 (setq recipients | |
127 (mail-strip-quoted-names | |
128 (mapconcat #'identity | |
129 (nconc (mail-fetch-field "to" nil nil t) | |
130 (mail-fetch-field "cc" nil nil t) | |
131 (mail-fetch-field "bcc" nil nil t)) | |
132 ",")))) | |
133 (if recipients | |
134 (setq recipients (delete "" | |
135 (split-string recipients "[ \t\n]+")))) | |
136 (goto-char (point-min)) | |
137 (if (search-forward mail-header-separator nil t) | |
138 (forward-line)) | |
139 (setq epa-last-coding-system-specified | |
140 (or coding-system-for-write | |
141 (epa--select-safe-coding-system (point) (point-max)))) | |
142 (list (point) (point-max) | |
143 (if verbose | |
144 (epa-select-keys | |
145 context | |
146 "Select recipients for encryption. | |
147 If no one is selected, symmetric encryption will be performed. " | |
148 recipients) | |
149 (if recipients | |
150 (mapcar | |
151 (lambda (recipient) | |
152 (setq recipient-key | |
153 (epa-mail--find-usable-key | |
154 (epg-list-keys | |
155 (epg-make-context epa-protocol) | |
156 (concat "<" recipient ">")) | |
157 'encrypt)) | |
158 (unless (or recipient-key | |
159 (y-or-n-p | |
160 (format | |
161 "No public key for %s; skip it? " | |
162 recipient))) | |
163 (error "No public key for %s" recipient)) | |
164 recipient-key) | |
165 recipients))) | |
166 (setq sign (if verbose (y-or-n-p "Sign? "))) | |
167 (if sign | |
168 (epa-select-keys context | |
169 "Select keys for signing. ")))))) | |
170 (epa-encrypt-region start end recipients sign signers)) | |
171 | |
172 ;;;###autoload | |
173 (defun epa-mail-import-keys () | |
174 "Import keys in the OpenPGP armor format in the current buffer. | |
175 The buffer is expected to contain a mail message. | |
176 | |
177 Don't use this command in Lisp programs!" | |
178 (interactive) | |
179 (epa-import-armor-in-region (point-min) (point-max))) | |
180 | |
91731
7efbdc83b944
EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents:
91687
diff
changeset
|
181 ;;;###autoload |
91733
e9326c8f35b0
EasyPG: Rename epa-mail-minor-mode to epa-global-mail-mode.
Michael Olson <mwolson@gnu.org>
parents:
91731
diff
changeset
|
182 (define-minor-mode epa-global-mail-mode |
91731
7efbdc83b944
EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents:
91687
diff
changeset
|
183 "Minor mode to hook EasyPG into Mail mode." |
7efbdc83b944
EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents:
91687
diff
changeset
|
184 :global t :init-value nil :group 'epa-mail :version "23.1" |
7efbdc83b944
EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents:
91687
diff
changeset
|
185 (remove-hook 'mail-mode-hook 'epa-mail-mode) |
91733
e9326c8f35b0
EasyPG: Rename epa-mail-minor-mode to epa-global-mail-mode.
Michael Olson <mwolson@gnu.org>
parents:
91731
diff
changeset
|
186 (if epa-global-mail-mode |
91731
7efbdc83b944
EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents:
91687
diff
changeset
|
187 (add-hook 'mail-mode-hook 'epa-mail-mode))) |
7efbdc83b944
EasyPG: Implement some suggestions from emacs-devel.
Michael Olson <mwolson@gnu.org>
parents:
91687
diff
changeset
|
188 |
91647 | 189 (provide 'epa-mail) |
190 | |
91687 | 191 ;; arch-tag: a6f82b3f-d177-4a11-af95-040da55927d2 |
91647 | 192 ;;; epa-mail.el ends here |