Klimi's new dotfiles with stow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.7 KiB

4 years ago
  1. ;;; helm-x-files.el --- helm auxiliary functions and sources. -*- lexical-binding: t -*-
  2. ;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;; This program is distributed in the hope that it will be useful,
  8. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;; GNU General Public License for more details.
  11. ;; You should have received a copy of the GNU General Public License
  12. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ;;; Code:
  14. (require 'helm-for-files)
  15. ;;; List of files gleaned from every dired buffer
  16. ;;
  17. ;;
  18. (defun helm-files-in-all-dired-candidates ()
  19. (save-excursion
  20. (cl-loop for (f . b) in dired-buffers
  21. when (buffer-live-p b)
  22. append (let ((dir (with-current-buffer b dired-directory)))
  23. (if (listp dir) (cdr dir)
  24. (directory-files f t dired-re-no-dot))))))
  25. ;; (dired '("~/" "~/.emacs.d/.emacs-custom.el" "~/.emacs.d/.emacs.bmk"))
  26. (defclass helm-files-dired-source (helm-source-sync helm-type-file)
  27. ((candidates :initform #'helm-files-in-all-dired-candidates)))
  28. (defvar helm-source-files-in-all-dired
  29. (helm-make-source "Files in all dired buffer." 'helm-files-dired-source))
  30. ;;; session.el files
  31. ;;
  32. ;; session (http://emacs-session.sourceforge.net/) is an alternative to
  33. ;; recentf that saves recent file history and much more.
  34. (defvar session-file-alist)
  35. (defclass helm-source-session-class (helm-source-sync)
  36. ((candidates :initform (lambda ()
  37. (cl-delete-if-not
  38. (lambda (f)
  39. (or (string-match helm-tramp-file-name-regexp f)
  40. (file-exists-p f)))
  41. (mapcar 'car session-file-alist))))
  42. (keymap :initform helm-generic-files-map)
  43. (help-message :initform helm-generic-file-help-message)
  44. (action :initform 'helm-type-file-actions)))
  45. (defvar helm-source-session nil
  46. "File list from emacs-session.")
  47. (defcustom helm-session-fuzzy-match nil
  48. "Enable fuzzy matching in `helm-source-session' when non--nil."
  49. :group 'helm-files
  50. :type 'boolean
  51. :set (lambda (var val)
  52. (set var val)
  53. (setq helm-source-session
  54. (helm-make-source "Session" 'helm-source-session-class
  55. :fuzzy-match val))))
  56. ;;; External searching file tools.
  57. ;;
  58. ;; Tracker desktop search
  59. (defun helm-source-tracker-transformer (candidates _source)
  60. ;; loop through tracker candidates selecting out file:// lines
  61. ;; then select part after file:// and url decode to get straight filenames
  62. (cl-loop for cand in candidates
  63. when (and (stringp cand)
  64. (string-match "\\`[[:space:]]*file://\\(.*\\)" cand))
  65. collect (url-unhex-string (match-string 1 cand))))
  66. (defvar helm-source-tracker-search
  67. (helm-build-async-source "Tracker Search"
  68. :candidates-process
  69. (lambda ()
  70. ;; the tracker-search command has been deprecated, now invoke via tracker
  71. ;; also, disable the contextual snippets which we don't currently use
  72. (start-process "tracker-search-process" nil
  73. "tracker" "search"
  74. "--disable-snippets"
  75. "--disable-color"
  76. "--limit=512"
  77. helm-pattern))
  78. ;; new simplified transformer of tracker search results
  79. :filtered-candidate-transformer #'helm-source-tracker-transformer
  80. ;;(multiline) ; https://github.com/emacs-helm/helm/issues/529
  81. :keymap helm-generic-files-map
  82. :action 'helm-type-file-actions
  83. :action-transformer '(helm-transform-file-load-el
  84. helm-transform-file-browse-url)
  85. :requires-pattern 3)
  86. "Source for retrieving files matching the current input pattern
  87. with the tracker desktop search.")
  88. ;; Spotlight (MacOS X desktop search)
  89. (defclass helm-mac-spotlight-source (helm-source-async helm-type-file)
  90. ((candidates-process :initform
  91. (lambda ()
  92. (start-process
  93. "mdfind-process" nil "mdfind" helm-pattern)))
  94. (requires-pattern :initform 3)))
  95. (defvar helm-source-mac-spotlight
  96. (helm-make-source "mdfind" 'helm-mac-spotlight-source)
  97. "Source for retrieving files via Spotlight's command line
  98. utility mdfind.")
  99. (provide 'helm-x-files)
  100. ;; Local Variables:
  101. ;; byte-compile-warnings: (not obsolete)
  102. ;; coding: utf-8
  103. ;; indent-tabs-mode: nil
  104. ;; End:
  105. ;;; helm-x-files.el ends here