Skip to content

Commit

Permalink
Merge pull request #233 from emacs-helm/bookmark-show-fname
Browse files Browse the repository at this point in the history
Issue #232 Implement bookmark show filename
  • Loading branch information
thierryvolpiatto committed Apr 4, 2013
2 parents a2ecf8c + 2fbaccc commit 0ddef7a
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 183 deletions.
12 changes: 0 additions & 12 deletions helm-aliases.el
Expand Up @@ -267,8 +267,6 @@
(make-obsolete 'helm-c-bookmark-info-setup-alist 'helm-bookmark-info-setup-alist "1.5.1") (make-obsolete 'helm-c-bookmark-info-setup-alist 'helm-bookmark-info-setup-alist "1.5.1")
(defalias 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute) (defalias 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute)
(make-obsolete 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute "1.5.1") (make-obsolete 'helm-c-ratpoison-commands-execute 'helm-ratpoison-commands-execute "1.5.1")
(defalias 'helm-c-collect-bookmarks 'helm-collect-bookmarks)
(make-obsolete 'helm-c-collect-bookmarks 'helm-collect-bookmarks "1.5.1")
(defalias 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward) (defalias 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward)
(make-obsolete 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward "1.5.1") (make-obsolete 'helm-c-ucs-persistent-backward 'helm-ucs-persistent-backward "1.5.1")
(defalias 'helm-c-info-pages-init 'helm-info-pages-init) (defalias 'helm-c-info-pages-init 'helm-info-pages-init)
Expand Down Expand Up @@ -331,8 +329,6 @@
(make-obsolete 'helm-c-top-sh 'helm-top-sh "1.5.1") (make-obsolete 'helm-c-top-sh 'helm-top-sh "1.5.1")
(defalias 'helm-c-bbdb-get-record 'helm-bbdb-get-record) (defalias 'helm-c-bbdb-get-record 'helm-bbdb-get-record)
(make-obsolete 'helm-c-bbdb-get-record 'helm-bbdb-get-record "1.5.1") (make-obsolete 'helm-c-bbdb-get-record 'helm-bbdb-get-record "1.5.1")
(defalias 'helm-c-bookmark-root-logged-p 'helm-bookmark-root-logged-p)
(make-obsolete 'helm-c-bookmark-root-logged-p 'helm-bookmark-root-logged-p "1.5.1")
(defalias 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action) (defalias 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action)
(make-obsolete 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action "1.5.1") (make-obsolete 'helm-c-persistent-xfont-action 'helm-persistent-xfont-action "1.5.1")
(defalias 'helm-c-latex-math-candidates 'helm-latex-math-candidates) (defalias 'helm-c-latex-math-candidates 'helm-latex-math-candidates)
Expand Down Expand Up @@ -497,8 +493,6 @@
(make-obsolete 'helm-c-find-file-or-marked 'helm-find-file-or-marked "1.5.1") (make-obsolete 'helm-c-find-file-or-marked 'helm-find-file-or-marked "1.5.1")
(defalias 'helm-c-query-replace-regexp 'helm-query-replace-regexp) (defalias 'helm-c-query-replace-regexp 'helm-query-replace-regexp)
(make-obsolete 'helm-c-query-replace-regexp 'helm-query-replace-regexp "1.5.1") (make-obsolete 'helm-c-query-replace-regexp 'helm-query-replace-regexp "1.5.1")
(defalias 'helm-c-bookmark-ssh-files-setup-alist 'helm-bookmark-ssh-files-setup-alist)
(make-obsolete 'helm-c-bookmark-ssh-files-setup-alist 'helm-bookmark-ssh-files-setup-alist "1.5.1")
(defalias 'helm-c-describe-variable 'helm-describe-variable) (defalias 'helm-c-describe-variable 'helm-describe-variable)
(make-obsolete 'helm-c-describe-variable 'helm-describe-variable "1.5.1") (make-obsolete 'helm-c-describe-variable 'helm-describe-variable "1.5.1")
(defalias 'helm-c-advice-persistent-action 'helm-advice-persistent-action) (defalias 'helm-c-advice-persistent-action 'helm-advice-persistent-action)
Expand Down Expand Up @@ -547,8 +541,6 @@
(make-obsolete 'helm-c-xrandr-info 'helm-xrandr-info "1.5.1") (make-obsolete 'helm-c-xrandr-info 'helm-xrandr-info "1.5.1")
(defalias 'helm-c-stringify 'helm-stringify) (defalias 'helm-c-stringify 'helm-stringify)
(make-obsolete 'helm-c-stringify 'helm-stringify "1.5.1") (make-obsolete 'helm-c-stringify 'helm-stringify "1.5.1")
(defalias 'helm-c-bookmark-su-files-setup-alist 'helm-bookmark-su-files-setup-alist)
(make-obsolete 'helm-c-bookmark-su-files-setup-alist 'helm-bookmark-su-files-setup-alist "1.5.1")
(defalias 'helm-c-goto-precedent-file 'helm-goto-precedent-file) (defalias 'helm-c-goto-precedent-file 'helm-goto-precedent-file)
(make-obsolete 'helm-c-goto-precedent-file 'helm-goto-precedent-file "1.5.1") (make-obsolete 'helm-c-goto-precedent-file 'helm-goto-precedent-file "1.5.1")
(defalias 'helm-c-apt-cache-show 'helm-apt-cache-show) (defalias 'helm-c-apt-cache-show 'helm-apt-cache-show)
Expand Down Expand Up @@ -732,8 +724,6 @@
(make-obsolete-variable 'helm-c-eldoc-in-minibuffer-show-fn 'helm-eldoc-in-minibuffer-show-fn "1.5.1") (make-obsolete-variable 'helm-c-eldoc-in-minibuffer-show-fn 'helm-eldoc-in-minibuffer-show-fn "1.5.1")
(defvaralias 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url) (defvaralias 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url)
(make-obsolete-variable 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url "1.5.1") (make-obsolete-variable 'helm-c-google-suggest-search-url 'helm-google-suggest-search-url "1.5.1")
(defvaralias 'helm-c-source-bookmark-su-files&dirs 'helm-source-bookmark-su-files&dirs)
(make-obsolete-variable 'helm-c-source-bookmark-su-files&dirs 'helm-source-bookmark-su-files&dirs "1.5.1")
(defvaralias 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook) (defvaralias 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook)
(make-obsolete-variable 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook "1.5.1") (make-obsolete-variable 'helm-c-source-bmkext-addressbook 'helm-source-bmkext-addressbook "1.5.1")
(defvaralias 'helm-c-source-ctags 'helm-source-ctags) (defvaralias 'helm-c-source-ctags 'helm-source-ctags)
Expand Down Expand Up @@ -778,8 +768,6 @@
(make-obsolete-variable 'helm-c-grep-use-ioccur-style-keys 'helm-grep-use-ioccur-style-keys "1.5.1") (make-obsolete-variable 'helm-c-grep-use-ioccur-style-keys 'helm-grep-use-ioccur-style-keys "1.5.1")
(defvaralias 'helm-c-ctags-modes 'helm-ctags-modes) (defvaralias 'helm-c-ctags-modes 'helm-ctags-modes)
(make-obsolete-variable 'helm-c-ctags-modes 'helm-ctags-modes "1.5.1") (make-obsolete-variable 'helm-c-ctags-modes 'helm-ctags-modes "1.5.1")
(defvaralias 'helm-c-source-bookmark-ssh-files&dirs 'helm-source-bookmark-ssh-files&dirs)
(make-obsolete-variable 'helm-c-source-bookmark-ssh-files&dirs 'helm-source-bookmark-ssh-files&dirs "1.5.1")
(defvaralias 'helm-c-source-moccur 'helm-source-moccur) (defvaralias 'helm-c-source-moccur 'helm-source-moccur)
(make-obsolete-variable 'helm-c-source-moccur 'helm-source-moccur "1.5.1") (make-obsolete-variable 'helm-c-source-moccur 'helm-source-moccur "1.5.1")
(defvaralias 'helm-c-source-w3m-bookmarks 'helm-source-w3m-bookmarks) (defvaralias 'helm-c-source-w3m-bookmarks 'helm-source-w3m-bookmarks)
Expand Down
114 changes: 44 additions & 70 deletions helm-bmkext.el
Expand Up @@ -15,6 +15,11 @@
;; You should have received a copy of the GNU General Public License ;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.


;; Dependency: https://github.com/thierryvolpiatto/emacs-bmk-ext
;; If you want to enable google-maps in addressbook you will need
;; Julien Danjou google-maps-el package available here:
;; http://julien.danjou.info/google-maps-el.html

;;; Code: ;;; Code:
(eval-when-compile (require 'cl)) (eval-when-compile (require 'cl))
(require 'helm) (require 'helm)
Expand All @@ -23,11 +28,9 @@


(declare-function bookmark-get-filename "bookmark" (bookmark-name-or-record)) (declare-function bookmark-get-filename "bookmark" (bookmark-name-or-record))


;; Dependency: https://github.com/thierryvolpiatto/emacs-bmk-ext
;; If you want to enable google-maps in addressbook you will need ;;; Filter functions
;; Julien Danjou google-maps-el package available here: ;;
;; http://julien.danjou.info/google-maps-el.html

(defun helm-bmkext-filter-setup-alist (fn &rest args) (defun helm-bmkext-filter-setup-alist (fn &rest args)
"Return a filtered `bookmark-alist' sorted alphabetically." "Return a filtered `bookmark-alist' sorted alphabetically."
(loop (loop
Expand All @@ -36,7 +39,7 @@
(funcall fn)) (funcall fn))
for i in alist for i in alist
for b = (car i) for b = (car i)
collect b into sa collect (propertize b 'location (bookmark-location b)) into sa
finally return (sort sa 'string-lessp))) finally return (sort sa 'string-lessp)))


;;;###autoload ;;;###autoload
Expand All @@ -45,6 +48,7 @@
(interactive) (interactive)
(helm-quit-and-execute-action 'bmkext-edit-bookmark)) (helm-quit-and-execute-action 'bmkext-edit-bookmark))



;;; Addressbook. ;;; Addressbook.
;; ;;
;; ;;
Expand All @@ -57,6 +61,8 @@
'global 'global
(helm-bmkext-addressbook-setup-alist)))) (helm-bmkext-addressbook-setup-alist))))
(candidates-in-buffer) (candidates-in-buffer)
(search helm-bookmark-search-fn)
(match-part . helm-pp-bookmark-match-fn)
(persistent-action (persistent-action
. (lambda (candidate) . (lambda (candidate)
(let ((bmk (helm-bookmark-get-bookmark-from-name (let ((bmk (helm-bookmark-get-bookmark-from-name
Expand Down Expand Up @@ -131,7 +137,9 @@
"Specialized filter function for bookmarks w3m." "Specialized filter function for bookmarks w3m."
(helm-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only)) (helm-bmkext-filter-setup-alist 'bmkext-addressbook-alist-only))


;; W3m bookmarks from bookmark-extensions.
;;; W3m bookmarks from bookmark-extensions.
;;
(defvar helm-source-bookmark-w3m (defvar helm-source-bookmark-w3m
'((name . "Bookmark W3m") '((name . "Bookmark W3m")
(init . (lambda () (init . (lambda ()
Expand All @@ -140,6 +148,8 @@
(helm-init-candidates-in-buffer (helm-init-candidates-in-buffer
'global (helm-bookmark-w3m-setup-alist)))) 'global (helm-bookmark-w3m-setup-alist))))
(candidates-in-buffer) (candidates-in-buffer)
(search helm-bookmark-search-fn)
(match-part . helm-pp-bookmark-match-fn)
(filtered-candidate-transformer (filtered-candidate-transformer
helm-adaptive-sort helm-adaptive-sort
helm-highlight-bookmark) helm-highlight-bookmark)
Expand All @@ -149,7 +159,9 @@
"Specialized filter function for bookmarks w3m." "Specialized filter function for bookmarks w3m."
(helm-bmkext-filter-setup-alist 'bmkext-w3m-alist-only)) (helm-bmkext-filter-setup-alist 'bmkext-w3m-alist-only))


;; Images
;;; Images
;;
(defvar helm-source-bookmark-images (defvar helm-source-bookmark-images
'((name . "Bookmark Images") '((name . "Bookmark Images")
(init . (lambda () (init . (lambda ()
Expand All @@ -158,6 +170,8 @@
(helm-init-candidates-in-buffer (helm-init-candidates-in-buffer
'global (helm-bookmark-images-setup-alist)))) 'global (helm-bookmark-images-setup-alist))))
(candidates-in-buffer) (candidates-in-buffer)
(search helm-bookmark-search-fn)
(match-part . helm-pp-bookmark-match-fn)
(filtered-candidate-transformer (filtered-candidate-transformer
helm-adaptive-sort helm-adaptive-sort
helm-highlight-bookmark) helm-highlight-bookmark)
Expand All @@ -167,7 +181,9 @@
"Specialized filter function for images bookmarks." "Specialized filter function for images bookmarks."
(helm-bmkext-filter-setup-alist 'bmkext-image-file-alist-only)) (helm-bmkext-filter-setup-alist 'bmkext-image-file-alist-only))


;; Woman Man
;;; Woman Man
;;
(defvar helm-source-bookmark-man (defvar helm-source-bookmark-man
'((name . "Bookmark Woman&Man") '((name . "Bookmark Woman&Man")
(init . (lambda () (init . (lambda ()
Expand All @@ -176,6 +192,8 @@
(helm-init-candidates-in-buffer (helm-init-candidates-in-buffer
'global (helm-bookmark-man-setup-alist)))) 'global (helm-bookmark-man-setup-alist))))
(candidates-in-buffer) (candidates-in-buffer)
(search helm-bookmark-search-fn)
(match-part . helm-pp-bookmark-match-fn)
(filtered-candidate-transformer (filtered-candidate-transformer
helm-adaptive-sort helm-adaptive-sort
helm-highlight-bookmark) helm-highlight-bookmark)
Expand All @@ -186,7 +204,9 @@
(append (helm-bmkext-filter-setup-alist 'bmkext-man-alist-only) (append (helm-bmkext-filter-setup-alist 'bmkext-man-alist-only)
(helm-bmkext-filter-setup-alist 'bmkext-woman-alist-only))) (helm-bmkext-filter-setup-alist 'bmkext-woman-alist-only)))


;; Gnus
;;; Gnus
;;
(defvar helm-source-bookmark-gnus (defvar helm-source-bookmark-gnus
'((name . "Bookmark Gnus") '((name . "Bookmark Gnus")
(init . (lambda () (init . (lambda ()
Expand All @@ -195,6 +215,8 @@
(helm-init-candidates-in-buffer (helm-init-candidates-in-buffer
'global (helm-bookmark-gnus-setup-alist)))) 'global (helm-bookmark-gnus-setup-alist))))
(candidates-in-buffer) (candidates-in-buffer)
(search helm-bookmark-search-fn)
(match-part . helm-pp-bookmark-match-fn)
(filtered-candidate-transformer (filtered-candidate-transformer
helm-adaptive-sort helm-adaptive-sort
helm-highlight-bookmark) helm-highlight-bookmark)
Expand All @@ -204,7 +226,9 @@
"Specialized filter function for bookmarks gnus." "Specialized filter function for bookmarks gnus."
(helm-bmkext-filter-setup-alist 'bmkext-gnus-alist-only)) (helm-bmkext-filter-setup-alist 'bmkext-gnus-alist-only))


;; Info
;;; Info
;;
(defvar helm-source-bookmark-info (defvar helm-source-bookmark-info
'((name . "Bookmark Info") '((name . "Bookmark Info")
(init . (lambda () (init . (lambda ()
Expand All @@ -213,6 +237,8 @@
(helm-init-candidates-in-buffer (helm-init-candidates-in-buffer
'global (helm-bookmark-info-setup-alist)))) 'global (helm-bookmark-info-setup-alist))))
(candidates-in-buffer) (candidates-in-buffer)
(search helm-bookmark-search-fn)
(match-part . helm-pp-bookmark-match-fn)
(filtered-candidate-transformer (filtered-candidate-transformer
helm-adaptive-sort helm-adaptive-sort
helm-highlight-bookmark) helm-highlight-bookmark)
Expand All @@ -222,7 +248,9 @@
"Specialized filter function for bookmarks info." "Specialized filter function for bookmarks info."
(helm-bmkext-filter-setup-alist 'bmkext-info-alist-only)) (helm-bmkext-filter-setup-alist 'bmkext-info-alist-only))


;; Local Files&directories
;;; Files and directories
;;
(defvar helm-source-bookmark-files&dirs (defvar helm-source-bookmark-files&dirs
'((name . "Bookmark Files&Directories") '((name . "Bookmark Files&Directories")
(init . (lambda () (init . (lambda ()
Expand All @@ -231,70 +259,18 @@
(helm-init-candidates-in-buffer (helm-init-candidates-in-buffer
'global (helm-bookmark-local-files-setup-alist)))) 'global (helm-bookmark-local-files-setup-alist))))
(candidates-in-buffer) (candidates-in-buffer)
(search helm-bookmark-search-fn)
(match-part . helm-pp-bookmark-match-fn)
(filtered-candidate-transformer (filtered-candidate-transformer
helm-adaptive-sort helm-adaptive-sort
helm-highlight-bookmark) helm-highlight-bookmark)
(type . bookmark))) (type . bookmark)))


(defun helm-bookmark-local-files-setup-alist () (defun helm-bookmark-local-files-setup-alist ()
"Specialized filter function for bookmarks locals files." "Specialized filter function for bookmarks locals files."
(helm-bmkext-filter-setup-alist 'bmkext-local-file-alist-only)) (helm-bmkext-filter-setup-alist 'bmkext-file-alist-only))

;; Su Files&directories
(defvar helm-source-bookmark-su-files&dirs
'((name . "Bookmark Root-Files&Directories")
(init . (lambda ()
(require 'bookmark-extensions)
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-su-files-setup-alist))))
(candidates-in-buffer)
(filtered-candidate-transformer
helm-adaptive-sort
helm-highlight-bookmark-su)
(type . bookmark)))

(defun helm-bookmark-su-files-setup-alist ()
"Specialized filter function for bookmarks su/sudo files."
(declare (special bmkext-su-or-sudo-regexp))
(loop
with l = (helm-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only)
for i in l
for isfile = (bookmark-get-filename i)
for istramp = (and isfile (boundp 'tramp-file-name-regexp)
(save-match-data
(string-match tramp-file-name-regexp isfile)))
for issu = (and istramp
(string-match bmkext-su-or-sudo-regexp isfile))
if issu
collect i))

;; Ssh Files&directories
(defvar helm-source-bookmark-ssh-files&dirs
'((name . "Bookmark Ssh-Files&Directories")
(init . (lambda ()
(require 'bookmark-extensions)
(bookmark-maybe-load-default-file)
(helm-init-candidates-in-buffer
'global (helm-bookmark-ssh-files-setup-alist))))
(candidates-in-buffer)
(filtered-candidate-transformer . helm-adaptive-sort)
(type . bookmark)))

(defun helm-bookmark-ssh-files-setup-alist ()
"Specialized filter function for bookmarks ssh files."
(loop
with l = (helm-bmkext-filter-setup-alist 'bmkext-remote-file-alist-only)
for i in l
for isfile = (bookmark-get-filename i)
for istramp = (and isfile (boundp 'tramp-file-name-regexp)
(save-match-data
(string-match tramp-file-name-regexp isfile)))
for isssh = (and istramp
(string-match "/ssh:" isfile))
if isssh
collect i))



;;;###autoload ;;;###autoload
(defun helm-bookmark-ext () (defun helm-bookmark-ext ()
"Preconfigured `helm' for bookmark-extensions sources. "Preconfigured `helm' for bookmark-extensions sources.
Expand All @@ -312,8 +288,6 @@ Contain also `helm-source-google-suggest'."
helm-source-bookmark-info helm-source-bookmark-info
helm-source-bookmark-man helm-source-bookmark-man
helm-source-bookmark-images helm-source-bookmark-images
helm-source-bookmark-su-files&dirs
helm-source-bookmark-ssh-files&dirs
helm-source-bookmark-set) helm-source-bookmark-set)
:prompt "SearchBookmark: " :prompt "SearchBookmark: "
:buffer "*helm bmkext*" :buffer "*helm bmkext*"
Expand Down

0 comments on commit 0ddef7a

Please sign in to comment.