Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 794 lines (696 sloc) 33.761 kb
530d89f @thierryvolpiatto Enable lexical-binding in all files.
thierryvolpiatto authored
1 ;;; helm-bookmark.el --- Helm for Emacs regular Bookmarks. -*- lexical-binding: t -*-
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
2
7c31479 @thierryvolpiatto Update copyrights.
thierryvolpiatto authored
3 ;; Copyright (C) 2012 ~ 2015 Thierry Volpiatto <thierry.volpiatto@gmail.com>
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
4
5 ;; This program is free software; you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
9
10 ;; This program is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
14
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 ;;; Code:
b740a4b @thierryvolpiatto Finish replacing cl symbols and requiring cl-lib, no compile error.
thierryvolpiatto authored
19 (require 'cl-lib)
7ca16b5 @thierryvolpiatto * helm-bookmark.el: require bookmark.
thierryvolpiatto authored
20 (require 'bookmark)
7d8197a @thierryvolpiatto Fix warnings at compilation.
thierryvolpiatto authored
21 (require 'helm)
22 (require 'helm-utils)
7974fc5 @thierryvolpiatto Create autoload system in helm-config.
thierryvolpiatto authored
23 (require 'helm-info)
4b28475 @thierryvolpiatto Rename all occurence of adaptative to adaptive.
thierryvolpiatto authored
24 (require 'helm-adaptive)
416e291 @thierryvolpiatto * helm-info.el (helm-info-at-point): Remove old google stuff.
thierryvolpiatto authored
25 (require 'helm-net)
7d8197a @thierryvolpiatto Fix warnings at compilation.
thierryvolpiatto authored
26
29fae98 @thierryvolpiatto * helm-bookmark.el: Fix edit bookmark.
thierryvolpiatto authored
27 (declare-function addressbook-bookmark-edit "ext:addressbook-bookmark.el" (bookmark))
e9384b7 @thierryvolpiatto * helm-bookmark.el: Declare functions to shutup byte-comp.
thierryvolpiatto authored
28 (declare-function message-buffers "message.el")
29 (declare-function addressbook-set-mail-buffer-1 "ext:addressbook-bookmark.el"
30 (&optional bookmark-name append cc))
29fae98 @thierryvolpiatto * helm-bookmark.el: Fix edit bookmark.
thierryvolpiatto authored
31
ba17f09 @thierryvolpiatto Move all defcustoms and faces in their respectives groups and files.
thierryvolpiatto authored
32
33 (defgroup helm-bookmark nil
34 "Predefined configurations for `helm.el'."
35 :group 'helm)
36
4dc273c @thierryvolpiatto Remove obsoletes sources and fn and use candidates.
thierryvolpiatto authored
37 (defcustom helm-bookmark-show-location nil
38 "Show location of bookmark on display."
39 :group 'helm-bookmark
40 :type 'boolean)
41
e3a7818 @thierryvolpiatto Allow customizing bookmark source list.
thierryvolpiatto authored
42 (defcustom helm-bookmark-default-filtered-sources
43 (append '(helm-source-bookmark-files&dirs
44 helm-source-bookmark-helm-find-files
45 helm-source-bookmark-info
46 helm-source-bookmark-gnus
47 helm-source-bookmark-man
48 helm-source-bookmark-images
49 helm-source-bookmark-w3m)
50 (and (locate-library "addressbook-bookmark")
51 (list 'helm-source-bookmark-addressbook))
52 (list 'helm-source-bookmark-uncategorized
53 'helm-source-bookmark-set))
54 "List of sources to use in `helm-filtered-bookmarks'."
55 :group 'helm-bookmark
56 :type '(repeat (choice symbol)))
57
5aa29bc @thierryvolpiatto * helm-bookmark.el: Cleanup.
thierryvolpiatto authored
58
1f842c5 @thierryvolpiatto * helm-bmkext.el: Move faces to bookmark and rename. remove group.
thierryvolpiatto authored
59 (defface helm-bookmark-info
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
60 '((t (:foreground "green")))
45cf362 @thierryvolpiatto * helm.el: Issue #50 Move some variables to defcustom and remove * in so...
thierryvolpiatto authored
61 "Face used for W3m Emacs bookmarks (not w3m bookmarks)."
1f842c5 @thierryvolpiatto * helm-bmkext.el: Move faces to bookmark and rename. remove group.
thierryvolpiatto authored
62 :group 'helm-bookmark)
63
64 (defface helm-bookmark-w3m
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
65 '((t (:foreground "yellow")))
45cf362 @thierryvolpiatto * helm.el: Issue #50 Move some variables to defcustom and remove * in so...
thierryvolpiatto authored
66 "Face used for W3m Emacs bookmarks (not w3m bookmarks)."
1f842c5 @thierryvolpiatto * helm-bmkext.el: Move faces to bookmark and rename. remove group.
thierryvolpiatto authored
67 :group 'helm-bookmark)
68
69 (defface helm-bookmark-gnus
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
70 '((t (:foreground "magenta")))
45cf362 @thierryvolpiatto * helm.el: Issue #50 Move some variables to defcustom and remove * in so...
thierryvolpiatto authored
71 "Face used for Gnus bookmarks."
1f842c5 @thierryvolpiatto * helm-bmkext.el: Move faces to bookmark and rename. remove group.
thierryvolpiatto authored
72 :group 'helm-bookmark)
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
73
1f842c5 @thierryvolpiatto * helm-bmkext.el: Move faces to bookmark and rename. remove group.
thierryvolpiatto authored
74 (defface helm-bookmark-man
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
75 '((t (:foreground "Orange4")))
45cf362 @thierryvolpiatto * helm.el: Issue #50 Move some variables to defcustom and remove * in so...
thierryvolpiatto authored
76 "Face used for Woman/man bookmarks."
1f842c5 @thierryvolpiatto * helm-bmkext.el: Move faces to bookmark and rename. remove group.
thierryvolpiatto authored
77 :group 'helm-bookmark)
78
79 (defface helm-bookmark-file
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
80 '((t (:foreground "Deepskyblue2")))
45cf362 @thierryvolpiatto * helm.el: Issue #50 Move some variables to defcustom and remove * in so...
thierryvolpiatto authored
81 "Face used for file bookmarks."
1f842c5 @thierryvolpiatto * helm-bmkext.el: Move faces to bookmark and rename. remove group.
thierryvolpiatto authored
82 :group 'helm-bookmark)
83
207fb36 @thierryvolpiatto Fix autoloads and remove faces variables.
thierryvolpiatto authored
84 (defface helm-bookmark-directory
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
85 '((t (:inherit helm-ff-directory)))
45cf362 @thierryvolpiatto * helm.el: Issue #50 Move some variables to defcustom and remove * in so...
thierryvolpiatto authored
86 "Face used for file bookmarks."
207fb36 @thierryvolpiatto Fix autoloads and remove faces variables.
thierryvolpiatto authored
87 :group 'helm-bookmark)
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
88
f8e0dbf @thierryvolpiatto * helm-bookmark.el (helm-bookmark-addressbook): New face.
thierryvolpiatto authored
89 (defface helm-bookmark-addressbook
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
90 '((t (:foreground "tomato")))
f8e0dbf @thierryvolpiatto * helm-bookmark.el (helm-bookmark-addressbook): New face.
thierryvolpiatto authored
91 "Face used for addressbook bookmarks."
92 :group 'helm-bookmark)
93
207fb36 @thierryvolpiatto Fix autoloads and remove faces variables.
thierryvolpiatto authored
94
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
95 (defvar helm-bookmark-map
b740a4b @thierryvolpiatto Finish replacing cl symbols and requiring cl-lib, no compile error.
thierryvolpiatto authored
96 (let ((map (make-sparse-keymap)))
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
97 (set-keymap-parent map helm-map)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
98 (define-key map (kbd "C-c o") 'helm-bookmark-run-jump-other-window)
99 (define-key map (kbd "C-d") 'helm-bookmark-run-delete)
b92acd5 @thierryvolpiatto * helm.el: Update keymap in *after-update-hook.
thierryvolpiatto authored
100 (define-key map (kbd "C-]") 'helm-bookmark-toggle-filename)
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
101 (define-key map (kbd "M-e") 'helm-bookmark-run-edit)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
102 (define-key map (kbd "C-c ?") 'helm-bookmark-help)
f60fc75 @thierryvolpiatto * helm-bookmark.el: Remove old functions from map.
thierryvolpiatto authored
103 map)
f9067e2 @thierryvolpiatto * helm-yaoddmuse.el: New file
thierryvolpiatto authored
104 "Generic Keymap for emacs bookmark sources.")
105
9589217 @thierryvolpiatto * helm-source.el: Allow inheritance of types.
thierryvolpiatto authored
106 (defclass helm-source-basic-bookmarks (helm-source-in-buffer helm-type-bookmark)
107 ((init :initform (lambda ()
108 (bookmark-maybe-load-default-file)
109 (helm-init-candidates-in-buffer
110 'global
111 (bookmark-all-names))))
112 (filtered-candidate-transformer :initform 'helm-bookmark-transformer)
113 (search :initform 'helm-bookmark-search-fn)))
114
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
115 (defvar helm-source-bookmarks
8cb7a9e @thierryvolpiatto * helm-source.el: Rename helm--make* to helm-make.
thierryvolpiatto authored
116 (helm-make-source "Bookmarks" 'helm-source-basic-bookmarks)
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
117 "See (info \"(emacs)Bookmarks\").")
118
40ada5b @thierryvolpiatto Fix unused args source in some filtered candidates functions.
thierryvolpiatto authored
119 (defun helm-bookmark-transformer (candidates _source)
b82caa8 @thierryvolpiatto replace all cl symbol by their cl-lib equivalent.
thierryvolpiatto authored
120 (cl-loop for i in candidates
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
121 for loc = (bookmark-location i)
122 for len = (string-width i)
123 for trunc = (if (> len bookmark-bmenu-file-column)
124 (helm-substring i bookmark-bmenu-file-column)
125 i)
126 for sep = (make-string (- (+ bookmark-bmenu-file-column 2)
92a641b @thierryvolpiatto * helm-bookmark.el: Fix toggle filenames with mu4e bookmarks.
thierryvolpiatto authored
127 (length trunc))
128 ? )
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
129 if helm-bookmark-show-location
338edf2 @thierryvolpiatto * helm-bookmark.el: Fix toggle filenames with mu4e also with normal book...
thierryvolpiatto authored
130 collect (cons (concat trunc sep (if (listp loc) (car loc) loc)) i)
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
131 else collect i))
d8361eb @thierryvolpiatto Implement bookmark show filename
thierryvolpiatto authored
132
133 (defun helm-bookmark-match-fn (candidate)
4178855 @thierryvolpiatto * helm-bookmark.el: Add docstring and comments.
thierryvolpiatto authored
134 "Match function for bookmark sources using `candidates'."
4dc273c @thierryvolpiatto Remove obsoletes sources and fn and use candidates.
thierryvolpiatto authored
135 (if helm-bookmark-show-location
4178855 @thierryvolpiatto * helm-bookmark.el: Add docstring and comments.
thierryvolpiatto authored
136 ;; match only location, match-plugin will match also name.
d8361eb @thierryvolpiatto Implement bookmark show filename
thierryvolpiatto authored
137 (string-match helm-pattern (bookmark-location candidate))
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
138 (string-match helm-pattern candidate)))
d8361eb @thierryvolpiatto Implement bookmark show filename
thierryvolpiatto authored
139
e4cd1be @thierryvolpiatto Fix Updating keymap with recursive minibuffers.
thierryvolpiatto authored
140 (defun helm-bookmark-toggle-filename-1 (_candidate)
141 (let* ((real (helm-get-selection helm-buffer))
142 (trunc (if (> (string-width real) bookmark-bmenu-file-column)
143 (helm-substring real bookmark-bmenu-file-column)
144 real))
145 (loc (bookmark-location real)))
146 (setq helm-bookmark-show-location (not helm-bookmark-show-location))
147 (helm-force-update (if helm-bookmark-show-location
148 (concat (regexp-quote trunc)
149 " +"
150 (regexp-quote
151 (if (listp loc) (car loc) loc)))
152 real))))
153
d8361eb @thierryvolpiatto Implement bookmark show filename
thierryvolpiatto authored
154 (defun helm-bookmark-toggle-filename ()
52be246 @thierryvolpiatto Update doc for bookmark.
thierryvolpiatto authored
155 "Toggle bookmark location visibility."
d8361eb @thierryvolpiatto Implement bookmark show filename
thierryvolpiatto authored
156 (interactive)
586425f @thierryvolpiatto Use with-helm-alive-p in many places and remove autoload cookies where n...
thierryvolpiatto authored
157 (with-helm-alive-p
e4cd1be @thierryvolpiatto Fix Updating keymap with recursive minibuffers.
thierryvolpiatto authored
158 (helm-attrset 'toggle-filename
159 '(helm-bookmark-toggle-filename-1 . never-split))
160 (helm-execute-persistent-action 'toggle-filename)))
d8361eb @thierryvolpiatto Implement bookmark show filename
thierryvolpiatto authored
161
5aa29bc @thierryvolpiatto * helm-bookmark.el: Cleanup.
thierryvolpiatto authored
162 (defun helm-bookmark-jump (candidate)
163 "Jump to bookmark from keyboard."
ab464a6 * helm-bookmark.el: Issue #259 bind non-essential.
thierry authored
164 (let ((current-prefix-arg helm-current-prefix-arg)
165 non-essential)
5aa29bc @thierryvolpiatto * helm-bookmark.el: Cleanup.
thierryvolpiatto authored
166 (bookmark-jump candidate)))
167
ab464a6 * helm-bookmark.el: Issue #259 bind non-essential.
thierry authored
168 (defun helm-bookmark-jump-other-window (candidate)
169 (let (non-essential)
170 (bookmark-jump-other-window candidate)))
171
5aa29bc @thierryvolpiatto * helm-bookmark.el: Cleanup.
thierryvolpiatto authored
172
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
173 ;;; bookmark-set
4dc273c @thierryvolpiatto Remove obsoletes sources and fn and use candidates.
thierryvolpiatto authored
174 ;;
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
175 (defvar helm-source-bookmark-set
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
176 '((name . "Set Bookmark")
177 (dummy)
178 (action . bookmark-set))
179 "See (info \"(emacs)Bookmarks\").")
180
5aa29bc @thierryvolpiatto * helm-bookmark.el: Cleanup.
thierryvolpiatto authored
181
4dc273c @thierryvolpiatto Remove obsoletes sources and fn and use candidates.
thierryvolpiatto authored
182 ;;; Colorize bookmarks by category
183 ;;
184 (defvar helm-source-pp-bookmarks
5f134be @thierryvolpiatto * helm-bookmark.el (helm-source-pp-bookmarks): Change source name.
thierryvolpiatto authored
185 '((name . "PP-Bookmarks")
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
186 (init . (lambda ()
a96af2a @thierryvolpiatto * helm-bookmark.el (helm-source-bookmarks): Use the init slot.
thierryvolpiatto authored
187 (bookmark-maybe-load-default-file)
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
188 (helm-init-candidates-in-buffer
1592c28 @thierryvolpiatto Reindent all files.
thierryvolpiatto authored
189 'global (cl-loop for b in (bookmark-all-names) collect
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
190 (propertize b 'location (bookmark-location b))))))
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
191 (candidates-in-buffer)
25b5a32 @thierryvolpiatto Fix some more cl-search typo.
thierryvolpiatto authored
192 (search helm-bookmark-search-fn)
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
193 (match-part . helm-pp-bookmark-match-fn)
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
194 (filtered-candidate-transformer
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
195 helm-adaptive-sort
196 helm-highlight-bookmark)
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
197 (type . bookmark))
198 "See (info \"(emacs)Bookmarks\").")
199
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
200 (defun helm-bookmark-search-fn (pattern)
4178855 @thierryvolpiatto * helm-bookmark.el: Add docstring and comments.
thierryvolpiatto authored
201 "Search function for bookmark sources using `candidates-in-buffer'.
202 Should be used with `helm-pp-bookmark-match-fn' as `match-part' function."
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
203 (if helm-bookmark-show-location
204 (helm-aif (next-single-property-change (point) 'location)
205 (goto-char it))
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
206 (re-search-forward pattern nil t)))
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
207
208 (defun helm-pp-bookmark-match-fn (candidate)
4178855 @thierryvolpiatto * helm-bookmark.el: Add docstring and comments.
thierryvolpiatto authored
209 "Search function for bookmark sources using `candidates-in-buffer'.
210 Should be used with `helm-bookmark-search-fn' as `search' function."
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
211 (helm-aif (and helm-bookmark-show-location
212 (bookmark-location candidate))
698005a @thierryvolpiatto * helm-bookmark.el (helm-pp-bookmark-match-fn): Match against name+loc.
thierryvolpiatto authored
213 ;; Match against bookmark-name and location.
214 (concat candidate " " it)
215 ;; Match against bookmark-name.
8658abd @thierryvolpiatto * helm-bookmark.el: Make pp-bookmarks searching/matching works with cand...
thierryvolpiatto authored
216 candidate))
217
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
218
219 ;;; Predicates
220 ;;
221 (defconst helm-bookmark--non-file-filename " - no file -"
222 "Name to use for `filename' entry, for non-file bookmarks.")
223
224 (defun helm-bookmark-gnus-bookmark-p (bookmark)
225 "Return non-nil if BOOKMARK is a Gnus bookmark.
226 BOOKMARK is a bookmark name or a bookmark record."
227 (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-gnus)
228 (eq (bookmark-get-handler bookmark) 'gnus-summary-bookmark-jump)
229 (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-gnus)))
230
231 (defun helm-bookmark-w3m-bookmark-p (bookmark)
232 "Return non-nil if BOOKMARK is a W3m bookmark.
233 BOOKMARK is a bookmark name or a bookmark record."
234 (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-w3m)
235 (eq (bookmark-get-handler bookmark) 'bookmark-w3m-bookmark-jump)
236 (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-w3m)))
237
238 (defun helm-bookmark-woman-bookmark-p (bookmark)
239 "Return non-nil if BOOKMARK is a Woman bookmark.
240 BOOKMARK is a bookmark name or a bookmark record."
241 (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-woman)
242 (eq (bookmark-get-handler bookmark) 'woman-bookmark-jump)
243 (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-woman)))
244
245 (defun helm-bookmark-man-bookmark-p (bookmark)
246 "Return non-nil if BOOKMARK is a Man bookmark.
247 BOOKMARK is a bookmark name or a bookmark record."
248 (or (eq (bookmark-get-handler bookmark) 'bmkext-jump-man)
249 (eq (bookmark-get-handler bookmark) 'Man-bookmark-jump)
250 (eq (bookmark-get-handler bookmark) 'bookmarkp-jump-man)))
251
252 (defun helm-bookmark-woman-man-bookmark-p (bookmark)
253 "Return non-nil if BOOKMARK is a Man or Woman bookmark.
254 BOOKMARK is a bookmark name or a bookmark record."
255 (or (helm-bookmark-man-bookmark-p bookmark)
256 (helm-bookmark-woman-bookmark-p bookmark)))
257
258 (defun helm-bookmark-info-bookmark-p (bookmark)
259 "Return non-nil if BOOKMARK is an Info bookmark.
260 BOOKMARK is a bookmark name or a bookmark record."
261 (eq (bookmark-get-handler bookmark) 'Info-bookmark-jump))
262
263 (defun helm-bookmark-image-bookmark-p (bookmark)
264 "Return non-nil if BOOKMARK bookmarks an image file."
265 (if (stringp bookmark)
266 (assoc 'image-type (assoc bookmark bookmark-alist))
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
267 (assoc 'image-type bookmark)))
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
268
269 (defun helm-bookmark-file-p (bookmark)
270 "Return non-nil if BOOKMARK bookmarks a file or directory.
271 BOOKMARK is a bookmark name or a bookmark record.
272 This excludes bookmarks of a more specific kind (Info, Gnus, and W3m)."
273 (let* ((filename (bookmark-get-filename bookmark))
274 (isnonfile (equal filename helm-bookmark--non-file-filename)))
275 (and filename (not isnonfile) (not (bookmark-get-handler bookmark)))))
276
24ac882 @thierryvolpiatto Add bookmark source for helm-find-files bookmarks.
thierryvolpiatto authored
277 (defun helm-bookmark-helm-find-files-p (bookmark)
278 "Return non-nil if BOOKMARK bookmarks a `helm-find-files' session.
279 BOOKMARK is a bookmark name or a bookmark record."
280 (eq (bookmark-get-handler bookmark) 'helm-ff-bookmark-jump))
281
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
282 (defun helm-bookmark-addressbook-p (bookmark)
5c7f779 @thierryvolpiatto * helm-bookmark.el: Add a source for bookmarks matching no categories.
thierryvolpiatto authored
283 "Return non--nil if BOOKMARK is a contact recorded with addressbook-bookmark.
284 BOOKMARK is a bookmark name or a bookmark record."
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
285 (if (listp bookmark)
286 (string= (assoc-default 'type bookmark) "addressbook")
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
287 (string= (assoc-default
288 'type (assoc bookmark bookmark-alist)) "addressbook")))
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
289
5c7f779 @thierryvolpiatto * helm-bookmark.el: Add a source for bookmarks matching no categories.
thierryvolpiatto authored
290 (defun helm-bookmark-uncategorized-bookmark-p (bookmark)
291 "Return non--nil if BOOKMARK match no known category."
24ac882 @thierryvolpiatto Add bookmark source for helm-find-files bookmarks.
thierryvolpiatto authored
292 (cl-loop for pred in '(helm-bookmark-addressbook-p
293 helm-bookmark-gnus-bookmark-p
294 helm-bookmark-w3m-bookmark-p
295 helm-bookmark-woman-man-bookmark-p
296 helm-bookmark-info-bookmark-p
297 helm-bookmark-image-bookmark-p
298 helm-bookmark-file-p
299 helm-bookmark-helm-find-files-p
300 helm-bookmark-addressbook-p)
301 never (funcall pred bookmark)))
5c7f779 @thierryvolpiatto * helm-bookmark.el: Add a source for bookmarks matching no categories.
thierryvolpiatto authored
302
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
303 (defun helm-bookmark-filter-setup-alist (fn)
304 "Return a filtered `bookmark-alist' sorted alphabetically."
305 (cl-loop with alist = (cl-loop for b in bookmark-alist
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
306 when (funcall fn b) collect b)
307 for bmk in alist
308 for name = (car bmk)
309 collect (propertize name 'location (bookmark-location name))))
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
310
311
6bfb463 @thierryvolpiatto * helm-bookmark.el: Enable helm adaptative in all filtered sources.
thierryvolpiatto authored
312 ;;; Bookmark handlers
313 ;;
2366bf2 @thierryvolpiatto * helm-bookmark.el: Preserve compatibility with old bookmarks entries. F...
thierryvolpiatto authored
314 (defvar w3m-async-exec)
315 (defun helm-bookmark-jump-w3m (bookmark)
1691564 @thierryvolpiatto * helm-bookmark.el: Add an alias for bookmark-w3m-bookmark-jump, add com...
thierryvolpiatto authored
316 "Jump to W3m bookmark BOOKMARK, setting a new tab.
317 If `browse-url-browser-function' is set to something else
318 than `w3m-browse-url' use it."
c056f85 @thierryvolpiatto * helm-bookmark.el (helm-bookmark-jump-w3m): require helm-net.
thierryvolpiatto authored
319 (require 'helm-net)
2366bf2 @thierryvolpiatto * helm-bookmark.el: Preserve compatibility with old bookmarks entries. F...
thierryvolpiatto authored
320 (let ((file (or (bookmark-prop-get bookmark 'filename)
321 (bookmark-prop-get bookmark 'url)))
322 (buf (generate-new-buffer-name "*w3m*"))
323 (w3m-async-exec nil)
324 (really-use-w3m (equal browse-url-browser-function 'w3m-browse-url)))
325 (helm-browse-url file really-use-w3m)
326 (when really-use-w3m
327 (bookmark-default-handler
328 `("" (buffer . ,buf) . ,(bookmark-get-bookmark-record bookmark))))))
329
1691564 @thierryvolpiatto * helm-bookmark.el: Add an alias for bookmark-w3m-bookmark-jump, add com...
thierryvolpiatto authored
330 ;; All bookmarks recorded with the handler provided with w3m
331 ;; (`bookmark-w3m-bookmark-jump') will use our handler which open
332 ;; the bookmark in a new tab or in an external browser depending
333 ;; on `browse-url-browser-function'.
334 (defalias 'bookmark-w3m-bookmark-jump 'helm-bookmark-jump-w3m)
335
336 ;; Provide compatibility with old handlers provided in external
337 ;; packages bookmark-extensions.el and bookmark+.
2366bf2 @thierryvolpiatto * helm-bookmark.el: Preserve compatibility with old bookmarks entries. F...
thierryvolpiatto authored
338 (defalias 'bmkext-jump-woman 'woman-bookmark-jump)
339 (defalias 'bmkext-jump-man 'Man-bookmark-jump)
340 (defalias 'bmkext-jump-w3m 'helm-bookmark-jump-w3m)
341 (defalias 'bmkext-jump-gnus 'gnus-summary-bookmark-jump)
342 (defalias 'bookmarkp-jump-gnus 'gnus-summary-bookmark-jump)
343 (defalias 'bookmarkp-jump-w3m 'helm-bookmark-jump-w3m)
344 (defalias 'bookmarkp-jump-woman 'woman-bookmark-jump)
345 (defalias 'bookmarkp-jump-man 'Man-bookmark-jump)
346
6bfb463 @thierryvolpiatto * helm-bookmark.el: Enable helm adaptative in all filtered sources.
thierryvolpiatto authored
347
348 ;;;; Filtered bookmark sources
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
349 ;;
350 ;;
351 (defclass helm-source-filtered-bookmarks (helm-source-in-buffer helm-type-bookmark)
352 ((search :initform #'helm-bookmark-search-fn)
353 (match-part :initform #'helm-pp-bookmark-match-fn)
354 (filtered-candidate-transformer
355 :initform '(helm-adaptive-sort
356 helm-highlight-bookmark))))
6bfb463 @thierryvolpiatto * helm-bookmark.el: Enable helm adaptative in all filtered sources.
thierryvolpiatto authored
357
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
358 ;;; W3m bookmarks.
359 ;;
360 (defun helm-bookmark-w3m-setup-alist ()
361 "Specialized filter function for bookmarks w3m."
362 (helm-bookmark-filter-setup-alist 'helm-bookmark-w3m-bookmark-p))
363
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
364 (defvar helm-source-bookmark-w3m
365 (helm-make-source "Bookmark W3m" 'helm-source-filtered-bookmarks
366 :init (lambda ()
367 (bookmark-maybe-load-default-file)
368 (helm-init-candidates-in-buffer
369 'global (helm-bookmark-w3m-setup-alist)))))
370
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
371 ;;; Images
372 ;;
373 (defun helm-bookmark-images-setup-alist ()
374 "Specialized filter function for images bookmarks."
375 (helm-bookmark-filter-setup-alist 'helm-bookmark-image-bookmark-p))
376
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
377 (defvar helm-source-bookmark-images
378 (helm-make-source "Bookmark Images" 'helm-source-filtered-bookmarks
379 :init (lambda ()
380 (bookmark-maybe-load-default-file)
381 (helm-init-candidates-in-buffer
382 'global (helm-bookmark-images-setup-alist)))))
383
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
384 ;;; Woman Man
385 ;;
386 (defun helm-bookmark-man-setup-alist ()
387 "Specialized filter function for bookmarks w3m."
388 (helm-bookmark-filter-setup-alist 'helm-bookmark-woman-man-bookmark-p))
389
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
390 (defvar helm-source-bookmark-man
391 (helm-make-source "Bookmark Woman&Man" 'helm-source-filtered-bookmarks
392 :init (lambda ()
393 (bookmark-maybe-load-default-file)
394 (helm-init-candidates-in-buffer
395 'global (helm-bookmark-man-setup-alist)))))
396
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
397 ;;; Gnus
398 ;;
399 (defun helm-bookmark-gnus-setup-alist ()
400 "Specialized filter function for bookmarks gnus."
401 (helm-bookmark-filter-setup-alist 'helm-bookmark-gnus-bookmark-p))
402
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
403 (defvar helm-source-bookmark-gnus
404 (helm-make-source "Bookmark Gnus" 'helm-source-filtered-bookmarks
405 :init (lambda ()
406 (bookmark-maybe-load-default-file)
407 (helm-init-candidates-in-buffer
408 'global (helm-bookmark-gnus-setup-alist)))))
409
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
410 ;;; Info
411 ;;
412 (defun helm-bookmark-info-setup-alist ()
413 "Specialized filter function for bookmarks info."
414 (helm-bookmark-filter-setup-alist 'helm-bookmark-info-bookmark-p))
415
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
416 (defvar helm-source-bookmark-info
417 (helm-make-source "Bookmark Info" 'helm-source-filtered-bookmarks
418 :init (lambda ()
419 (bookmark-maybe-load-default-file)
420 (helm-init-candidates-in-buffer
421 'global (helm-bookmark-info-setup-alist)))))
422
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
423 ;;; Files and directories
424 ;;
425 (defun helm-bookmark-local-files-setup-alist ()
426 "Specialized filter function for bookmarks locals files."
427 (helm-bookmark-filter-setup-alist 'helm-bookmark-file-p))
428
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
429 (defvar helm-source-bookmark-files&dirs
430 (helm-make-source "Bookmark Files&Directories" 'helm-source-filtered-bookmarks
431 :init (lambda ()
432 (bookmark-maybe-load-default-file)
433 (helm-init-candidates-in-buffer
434 'global (helm-bookmark-local-files-setup-alist)))))
435
24ac882 @thierryvolpiatto Add bookmark source for helm-find-files bookmarks.
thierryvolpiatto authored
436 ;;; Helm find files sessions.
437 ;;
438 (defun helm-bookmark-helm-find-files-setup-alist ()
439 "Specialized filter function for `helm-find-files' bookmarks."
440 (helm-bookmark-filter-setup-alist 'helm-bookmark-helm-find-files-p))
441
442 (defvar helm-source-bookmark-helm-find-files
443 (helm-make-source "Bookmark helm-find-files sessions" 'helm-source-filtered-bookmarks
444 :init (lambda ()
445 (bookmark-maybe-load-default-file)
446 (helm-init-candidates-in-buffer
447 'global (helm-bookmark-helm-find-files-setup-alist)))))
448
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
449 ;;; Uncategorized bookmarks
450 ;;
451 (defun helm-bookmark-uncategorized-setup-alist ()
452 "Specialized filter function for uncategorized bookmarks."
453 (helm-bookmark-filter-setup-alist 'helm-bookmark-uncategorized-bookmark-p))
454
455 (defvar helm-source-bookmark-uncategorized
456 (helm-make-source "Bookmark uncategorized" 'helm-source-filtered-bookmarks
457 :init (lambda ()
458 (bookmark-maybe-load-default-file)
459 (helm-init-candidates-in-buffer
460 'global (helm-bookmark-uncategorized-setup-alist)))))
461
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
462 ;;; Addressbook.
463 ;;
464 ;;
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
465 (defclass helm-bookmark-addressbook-class (helm-source-in-buffer)
466 ((init :initform (lambda ()
467 (require 'addressbook-bookmark nil t)
468 (bookmark-maybe-load-default-file)
469 (helm-init-candidates-in-buffer
470 'global
471 (helm-bookmark-addressbook-setup-alist))))
472 (search :initform #'helm-bookmark-search-fn)
473 (match-part :initform #'helm-pp-bookmark-match-fn)
474 (persistent-action :initform
475 (lambda (candidate)
476 (let ((bmk (helm-bookmark-get-bookmark-from-name
477 candidate)))
478 (bookmark--jump-via bmk 'switch-to-buffer))))
479 (persistent-help :initform "Show contact - Prefix with C-u to append")
480 (filtered-candidate-transformer :initform
481 '(helm-adaptive-sort
482 helm-highlight-bookmark))
483 (action :initform (("Show Contact(s)"
484 . (lambda (candidate)
485 (let* ((contacts (helm-marked-candidates))
486 (current-prefix-arg helm-current-prefix-arg))
487 (bookmark-jump
488 (helm-bookmark-get-bookmark-from-name (car contacts)))
489 (helm-aif (cdr contacts)
490 (let ((current-prefix-arg '(4)))
491 (cl-loop for bmk in it do
492 (bookmark-jump
493 (helm-bookmark-get-bookmark-from-name bmk))))))))
494 ("Mail To" . helm-bookmark-addressbook-send-mail-1)
495 ("Mail Cc" . (lambda (_candidate)
496 (helm-bookmark-addressbook-send-mail-1 nil 'cc)))
497 ("Mail Bcc" . (lambda (_candidate)
498 (helm-bookmark-addressbook-send-mail-1 nil 'bcc)))
499 ("Edit Bookmark"
500 . (lambda (candidate)
501 (let ((bmk (helm-bookmark-get-bookmark-from-name
502 candidate)))
503 (addressbook-bookmark-edit
504 (assoc bmk bookmark-alist)))))
505 ("Delete bookmark(s)" . helm-delete-marked-bookmarks)
506 ("Insert Email at point"
507 . (lambda (candidate)
508 (let* ((bmk (helm-bookmark-get-bookmark-from-name
509 candidate))
510 (mlist (split-string
511 (assoc-default
512 'email (assoc bmk bookmark-alist))
513 ", ")))
514 (insert
515 (if (> (length mlist) 1)
516 (helm-comp-read
517 "Insert Mail Address: " mlist :must-match t)
518 (car mlist))))))
519 ("Show annotation"
520 . (lambda (candidate)
521 (let ((bmk (helm-bookmark-get-bookmark-from-name
522 candidate)))
523 (bookmark-show-annotation bmk))))
524 ("Edit annotation"
525 . (lambda (candidate)
526 (let ((bmk (helm-bookmark-get-bookmark-from-name
527 candidate)))
528 (bookmark-edit-annotation bmk))))
529 ("Show Google map"
530 . (lambda (candidate)
531 (let* ((bmk (helm-bookmark-get-bookmark-from-name
532 candidate))
533 (full-bmk (assoc bmk bookmark-alist)))
534 (addressbook-google-map full-bmk))))))))
535
5fac3d8 @thierryvolpiatto * helm-bookmark.el: Add cc and bcc actions in addressbook.
thierryvolpiatto authored
536 (defun helm-bookmark-addressbook-send-mail-1 (_candidate &optional cc)
537 (let* ((contacts (helm-marked-candidates))
538 (bookmark (helm-bookmark-get-bookmark-from-name
539 (car contacts)))
540 (append (message-buffers)))
541 (addressbook-set-mail-buffer-1 bookmark append)
542 (helm-aif (cdr contacts)
543 (progn
544 (when cc (addressbook-set-mail-buffer-1 (car it) nil cc))
545 (cl-loop for bmk in (cdr it) do
546 (addressbook-set-mail-buffer-1
547 (helm-bookmark-get-bookmark-from-name bmk) 'append cc))))))
548
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
549 (defun helm-bookmark-addressbook-setup-alist ()
550 "Specialized filter function for addressbook bookmarks."
551 (helm-bookmark-filter-setup-alist 'helm-bookmark-addressbook-p))
552
d2782d6 @thierryvolpiatto Use helm-source to setup filtered bookmark sources.
thierryvolpiatto authored
553 (defvar helm-source-bookmark-addressbook
554 (helm-make-source "Bookmark Addressbook" 'helm-bookmark-addressbook-class))
5c7f779 @thierryvolpiatto * helm-bookmark.el: Add a source for bookmarks matching no categories.
thierryvolpiatto authored
555
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
556 ;;; Transformer
557 ;;
558
9b50655 @thierryvolpiatto Keep fixing unused args
thierryvolpiatto authored
559 (defun helm-highlight-bookmark (bookmarks _source)
cc396cb @thierryvolpiatto * helm-bookmark.el (helm-highlight-bookmark): Simplify loop, fix long li...
thierryvolpiatto authored
560 "Used as `filtered-candidate-transformer' to colorize bookmarks.
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
561 Work both with standard Emacs bookmarks and bookmark-extensions.el."
fc240e4 @thierryvolpiatto * helm.el (helm-get-candidates): Use one new attr `no-delay-on-input'. p...
thierryvolpiatto authored
562 (let ((non-essential t))
b82caa8 @thierryvolpiatto replace all cl symbol by their cl-lib equivalent.
thierryvolpiatto authored
563 (cl-loop for i in bookmarks
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
564 for isfile = (bookmark-get-filename i)
9643c8b @thierryvolpiatto * helm-bookmark.el (helm-highlight-bookmark): Fix helm-find-files bmk hi...
thierryvolpiatto authored
565 for hff = (helm-bookmark-helm-find-files-p i)
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
566 for handlerp = (and (fboundp 'bookmark-get-handler)
567 (bookmark-get-handler i))
568 for isw3m = (and (fboundp 'helm-bookmark-w3m-bookmark-p)
569 (helm-bookmark-w3m-bookmark-p i))
570 for isgnus = (and (fboundp 'helm-bookmark-gnus-bookmark-p)
571 (helm-bookmark-gnus-bookmark-p i))
572 for isman = (and (fboundp 'helm-bookmark-man-bookmark-p) ; Man
573 (helm-bookmark-man-bookmark-p i))
574 for iswoman = (and (fboundp 'helm-bookmark-woman-bookmark-p) ; Woman
575 (helm-bookmark-woman-bookmark-p i))
576 for isannotation = (bookmark-get-annotation i)
577 for isabook = (string= (bookmark-prop-get i 'type)
578 "addressbook")
579 for isinfo = (eq handlerp 'Info-bookmark-jump)
580 for loc = (bookmark-location i)
581 for len = (string-width i)
582 for trunc = (if (and helm-bookmark-show-location
583 (> len bookmark-bmenu-file-column))
584 (helm-substring
585 i bookmark-bmenu-file-column)
586 i)
587 ;; Add a * if bookmark have annotation
588 if (and isannotation (not (string-equal isannotation "")))
589 do (setq trunc (concat "*" (if helm-bookmark-show-location trunc i)))
590 for sep = (and helm-bookmark-show-location
591 (make-string (- (+ bookmark-bmenu-file-column 2)
92a641b @thierryvolpiatto * helm-bookmark.el: Fix toggle filenames with mu4e bookmarks.
thierryvolpiatto authored
592 (string-width trunc))
593 ? ))
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
594 for bmk = (cond ( ;; info buffers
595 isinfo
596 (propertize trunc 'face 'helm-bookmark-info
597 'help-echo isfile))
598 ( ;; w3m buffers
599 isw3m
600 (propertize trunc 'face 'helm-bookmark-w3m
601 'help-echo isfile))
602 ( ;; gnus buffers
603 isgnus
604 (propertize trunc 'face 'helm-bookmark-gnus
605 'help-echo isfile))
606 ( ;; Man Woman
607 (or iswoman isman)
608 (propertize trunc 'face 'helm-bookmark-man
609 'help-echo isfile))
610 ( ;; Addressbook
611 isabook
612 (propertize trunc 'face 'helm-bookmark-addressbook))
613 ( ;; directories
614 (and isfile
9643c8b @thierryvolpiatto * helm-bookmark.el (helm-highlight-bookmark): Fix helm-find-files bmk hi...
thierryvolpiatto authored
615 (or hff
b9c7ca6 @thierryvolpiatto * helm-bookmark.el (helm-highlight-bookmark): Fix again hff bookmarks hi...
thierryvolpiatto authored
616 ;; This is needed because `non-essential'
617 ;; is not working on Emacs-24.2 and the behavior
618 ;; of tramp seems to have changed since previous
619 ;; versions (Need to reenter password even if a
620 ;; first connection have been established,
621 ;; probably when host is named differently
622 ;; i.e machine/localhost)
623 (and (not (file-remote-p isfile))
624 (file-directory-p isfile))))
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
625 (propertize trunc 'face 'helm-bookmark-directory
626 'help-echo isfile))
627 ( ;; regular files
628 t
629 (propertize trunc 'face 'helm-bookmark-file
630 'help-echo isfile)))
631 collect (if helm-bookmark-show-location
92a641b @thierryvolpiatto * helm-bookmark.el: Fix toggle filenames with mu4e bookmarks.
thierryvolpiatto authored
632 (cons (concat bmk sep (if (listp loc) (car loc) loc))
297d5f0 @thierryvolpiatto * helm-bookmark.el: reindent one line, no code change.
thierryvolpiatto authored
633 i)
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
634 (cons bmk i)))))
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
635
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
636 (defun helm-bookmark-edit-bookmark (bookmark-name)
637 "Edit bookmark's name and file name, and maybe save them.
638 BOOKMARK-NAME is the current (old) name of the bookmark to be renamed."
29fae98 @thierryvolpiatto * helm-bookmark.el: Fix edit bookmark.
thierryvolpiatto authored
639 (let ((bmk (helm-bookmark-get-bookmark-from-name bookmark-name))
640 (handler (bookmark-prop-get bookmark-name 'handler)))
641 (if (eq handler 'addressbook-bookmark-jump)
642 (addressbook-bookmark-edit
643 (assoc bmk bookmark-alist))
644 (helm-bookmark-edit-bookmark-1 bookmark-name handler))))
645
646 (defun helm-bookmark-edit-bookmark-1 (bookmark-name handler)
1c593c9 @thierryvolpiatto * helm-bookmark.el (helm-bookmark-edit-bookmark-1): Bind helm--reading-p...
thierryvolpiatto authored
647 (let* ((helm--reading-passwd-or-string t)
648 (bookmark-fname (bookmark-get-filename bookmark-name))
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
649 (bookmark-loc (bookmark-prop-get bookmark-name 'location))
650 (new-name (read-from-minibuffer "Name: " bookmark-name))
651 (new-loc (read-from-minibuffer "FileName or Location: "
78d1bfe @thierryvolpiatto * helm-bookmark.el (helm-bookmark-edit-bookmark): Fix edition of mu4e bo...
thierryvolpiatto authored
652 (or bookmark-fname
653 (if (consp bookmark-loc)
654 (car bookmark-loc)
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
655 bookmark-loc))))
29fae98 @thierryvolpiatto * helm-bookmark.el: Fix edit bookmark.
thierryvolpiatto authored
656 (docid (and (eq handler 'mu4e-bookmark-jump)
657 (read-number "Docid: " (cdr bookmark-loc)))))
78d1bfe @thierryvolpiatto * helm-bookmark.el (helm-bookmark-edit-bookmark): Fix edition of mu4e bo...
thierryvolpiatto authored
658 (when docid
659 (setq new-loc (cons new-loc docid)))
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
660 (when (and (not (equal new-name "")) (not (equal new-loc ""))
661 (y-or-n-p "Save changes? "))
662 (if bookmark-fname
663 (progn
664 (helm-bookmark-rename bookmark-name new-name 'batch)
665 (bookmark-set-filename new-name new-loc))
bc4fb13 @thierryvolpiatto Finally reindent with the cl indentation behavior of 24.4.50.
thierryvolpiatto authored
666 (bookmark-prop-set
667 (bookmark-get-bookmark bookmark-name) 'location new-loc)
668 (helm-bookmark-rename bookmark-name new-name 'batch))
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
669 (helm-bookmark-maybe-save-bookmark)
670 (list new-name new-loc))))
671
672 (defun helm-bookmark-maybe-save-bookmark ()
673 "Increment save counter and maybe save `bookmark-alist'."
674 (setq bookmark-alist-modification-count (1+ bookmark-alist-modification-count))
675 (when (bookmark-time-to-save-p) (bookmark-save)))
676
677 (defun helm-bookmark-rename (old &optional new batch)
678 "Change bookmark's name from OLD to NEW.
679 Interactively:
680 If called from the keyboard, then prompt for OLD.
681 If called from the menubar, select OLD from a menu.
682 If NEW is nil, then prompt for its string value.
683
684 If BATCH is non-nil, then do not rebuild the menu list.
685
686 While the user enters the new name, repeated `C-w' inserts consecutive
687 words from the buffer into the new bookmark name."
688 (interactive (list (bookmark-completing-read "Old bookmark name")))
689 (bookmark-maybe-historicize-string old)
690 (bookmark-maybe-load-default-file)
691 (save-excursion (skip-chars-forward " ") (setq bookmark-yank-point (point)))
692 (setq bookmark-current-buffer (current-buffer))
693 (let ((newname (or new (read-from-minibuffer
694 "New name: " nil
695 (let ((now-map (copy-keymap minibuffer-local-map)))
696 (define-key now-map "\C-w" 'bookmark-yank-word)
697 now-map)
698 nil 'bookmark-history))))
699 (bookmark-set-name old newname)
700 (setq bookmark-current-bookmark newname)
701 (unless batch (bookmark-bmenu-surreptitiously-rebuild-list))
702 (helm-bookmark-maybe-save-bookmark) newname))
703
704 (defun helm-bookmark-run-edit ()
705 "Run `helm-bookmark-edit-bookmark' from keyboard."
706 (interactive)
707 (with-helm-alive-p
5a986c5 @thierryvolpiatto * helm-bookmark.el (helm-bookmark-edit-bookmark): Fix name.
thierryvolpiatto authored
708 (helm-quit-and-execute-action 'helm-bookmark-edit-bookmark)))
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
709
5aa29bc @thierryvolpiatto * helm-bookmark.el: Cleanup.
thierryvolpiatto authored
710
711 ;;; Bookmarks attributes
712 ;;
7974fc5 @thierryvolpiatto Create autoload system in helm-config.
thierryvolpiatto authored
713 (define-helm-type-attribute 'bookmark
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
714 `((coerce . helm-bookmark-get-bookmark-from-name)
2f88f0f @thierryvolpiatto * helm-bookmark.el: Use helm-make-actions
thierryvolpiatto authored
715 (action . ,(helm-make-actions
716 "Jump to bookmark" 'helm-bookmark-jump
717 "Jump to BM other window" 'helm-bookmark-jump-other-window
718 "Bookmark edit annotation" 'bookmark-edit-annotation
719 "Bookmark show annotation" 'bookmark-show-annotation
720 "Delete bookmark(s)" 'helm-delete-marked-bookmarks
721 "Edit Bookmark" 'helm-bookmark-edit-bookmark
722 "Rename bookmark" 'helm-bookmark-rename
723 "Relocate bookmark" 'bookmark-relocate))
9bc2702 @thierryvolpiatto Reindent all again.
thierryvolpiatto authored
724 (keymap . ,helm-bookmark-map)
725 (mode-line . helm-bookmark-mode-line-string))
7974fc5 @thierryvolpiatto Create autoload system in helm-config.
thierryvolpiatto authored
726 "Bookmark name.")
727
5aa29bc @thierryvolpiatto * helm-bookmark.el: Cleanup.
thierryvolpiatto authored
728
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
729 (defun helm-bookmark-run-jump-other-window ()
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
730 "Jump to bookmark from keyboard."
731 (interactive)
586425f @thierryvolpiatto Use with-helm-alive-p in many places and remove autoload cookies where n...
thierryvolpiatto authored
732 (with-helm-alive-p
733 (helm-quit-and-execute-action 'bookmark-jump-other-window)))
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
734
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
735 (defun helm-bookmark-run-delete ()
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
736 "Delete bookmark from keyboard."
737 (interactive)
586425f @thierryvolpiatto Use with-helm-alive-p in many places and remove autoload cookies where n...
thierryvolpiatto authored
738 (with-helm-alive-p
296219b @thierryvolpiatto * helm-bookmark.el (helm-bookmark-run-delete): Fix y-or-n-p prompt.
thierryvolpiatto authored
739 (when (y-or-n-p "Delete bookmark(s)?")
586425f @thierryvolpiatto Use with-helm-alive-p in many places and remove autoload cookies where n...
thierryvolpiatto authored
740 (helm-quit-and-execute-action 'helm-delete-marked-bookmarks))))
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
741
1a766bf @thierryvolpiatto * helm-color.el: New
thierryvolpiatto authored
742 (defun helm-bookmark-get-bookmark-from-name (bmk)
743 "Return bookmark name even if it is a bookmark with annotation.
7986b32 @thierryvolpiatto * helm-bookmark.el (helm-bookmark-get-bookmark-from-name): Don't check f...
thierryvolpiatto authored
744 e.g prepended with *."
55d7769 @thierryvolpiatto * helm-utils.el (helm-quit-and-find-file): Handle bookmark files (#595).
thierryvolpiatto authored
745 (let ((bookmark (replace-regexp-in-string "\\`\\*" "" bmk)))
7986b32 @thierryvolpiatto * helm-bookmark.el (helm-bookmark-get-bookmark-from-name): Don't check f...
thierryvolpiatto authored
746 (if (assoc bookmark bookmark-alist) bookmark bmk)))
1a766bf @thierryvolpiatto * helm-color.el: New
thierryvolpiatto authored
747
9b50655 @thierryvolpiatto Keep fixing unused args
thierryvolpiatto authored
748 (defun helm-delete-marked-bookmarks (_ignore)
1a766bf @thierryvolpiatto * helm-color.el: New
thierryvolpiatto authored
749 "Delete this bookmark or all marked bookmarks."
b82caa8 @thierryvolpiatto replace all cl symbol by their cl-lib equivalent.
thierryvolpiatto authored
750 (cl-dolist (i (helm-marked-candidates))
1a766bf @thierryvolpiatto * helm-color.el: New
thierryvolpiatto authored
751 (bookmark-delete (helm-bookmark-get-bookmark-from-name i)
752 'batch)))
753
754
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
755 ;;;###autoload
756 (defun helm-bookmarks ()
757 "Preconfigured `helm' for bookmarks."
758 (interactive)
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
759 (helm :sources '(helm-source-bookmarks
760 helm-source-bookmark-set)
344cea5 @thierryvolpiatto Add default arg for bookmark commands.
thierryvolpiatto authored
761 :buffer "*helm bookmarks*"
762 :default (buffer-name helm-current-buffer)))
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
763
764 ;;;###autoload
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
765 (defun helm-pp-bookmarks ()
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
766 "Preconfigured `helm' for bookmarks (pretty-printed)."
767 (interactive)
4dc273c @thierryvolpiatto Remove obsoletes sources and fn and use candidates.
thierryvolpiatto authored
768 (helm :sources '(helm-source-pp-bookmarks
4166d8a @thierryvolpiatto Replace "helm-c-" prefix by "helm-" in all files.
thierryvolpiatto authored
769 helm-source-bookmark-set)
344cea5 @thierryvolpiatto Add default arg for bookmark commands.
thierryvolpiatto authored
770 :buffer "*helm pp bookmarks*"
771 :default (buffer-name helm-current-buffer)))
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
772
b29f3ce @thierryvolpiatto * helm-bookmark.el: Add most functionalities of *bmkext but without the ...
thierryvolpiatto authored
773 ;;;###autoload
774 (defun helm-filtered-bookmarks ()
775 "Preconfigured helm for bookmarks (filtered by category).
776 Optional source `helm-source-bookmark-addressbook' is loaded
777 only if external library addressbook-bookmark.el is available."
778 (interactive)
e3a7818 @thierryvolpiatto Allow customizing bookmark source list.
thierryvolpiatto authored
779 (helm :sources helm-bookmark-default-filtered-sources
fe8195d @thierryvolpiatto * helm-bmkext.el: deleted file.
thierryvolpiatto authored
780 :prompt "Search Bookmark: "
781 :buffer "*helm filtered bookmarks*"
577ff40 @thierryvolpiatto * helm-bookmark.el (helm-filtered-bookmarks): Change :default to a list.
thierryvolpiatto authored
782 :default (list (thing-at-point 'symbol)
783 (buffer-name helm-current-buffer))))
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
784
785 (provide 'helm-bookmark)
786
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
787 ;; Local Variables:
a7ee65b @thierryvolpiatto Disable compile warnings and add new keyword to helm.
thierryvolpiatto authored
788 ;; byte-compile-warnings: (not cl-functions obsolete)
37b4201 @thierryvolpiatto Fix dependencies and autoloads. Reorder.
thierryvolpiatto authored
789 ;; coding: utf-8
790 ;; indent-tabs-mode: nil
791 ;; End:
792
9fbbdb9 @thierryvolpiatto * helm-bookmark.el: new
thierryvolpiatto authored
793 ;;; helm-bookmark.el ends here
Something went wrong with that request. Please try again.