Skip to content

Commit

Permalink
Fix: Use static autoload definitions for macro-defined commands
Browse files Browse the repository at this point in the history
Also delete autoloads for the macro definitions.  This prevents
helm-org-rifle from causing org to load unnecessarily.

Fixes #13.  Closes #20.  Thanks to Anders Johansson (@andersjohansson)
and Chris Ruegge (@cruegge).
  • Loading branch information
andersjohansson authored and alphapapa committed Jan 15, 2018
1 parent 13c15b7 commit cd875b7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 3 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ Run one of the rifle commands, type some words, and results will be displayed, g

** 1.6.0-pre

Nothing yet. Find me some more bugs to fix!
*Fixes*
+ Use static autoload definitions for macro-defined commands, and delete autoloads for the macro definitions. This prevents =helm-org-rifle= from causing =org= to load unnecessarily. Fixes #13. Thanks to Anders Johansson (@andersjohansson) and Chris Ruegge (@cruegge).

** 1.5.0

Expand Down Expand Up @@ -183,6 +184,7 @@ Nothing yet. Find me some more bugs to fix!
+ Thanks to Jorgen Schäfer for [[https://github.com/jorgenschaefer/emacs-buttercup][Buttercup]], which makes testing simple.
+ Thanks to [[https://github.com/joonoro][Joonatan O'Rourke]] for suggesting the =(org-agenda-files)= function.
+ Thanks to [[https://github.com/zeltak][@zeltak]] for helping to test many changes.
+ Thanks to [[https://github.com/andersjohansson][Anders Johansson]] and [[https://github.com/cruegge][Chris Ruegge]] for investigating and fixing the [[https://github.com/alphapapa/helm-org-rifle/issues/13][command-macro autoloads]].

* Development :noexport_1:

Expand Down
25 changes: 12 additions & 13 deletions helm-org-rifle.el
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ Just in case this is a performance issue for anyone, it can be disabled."

;;;;; Commands

;;;###autoload
(cl-defmacro helm-org-rifle-define-command (name args docstring &key sources (let nil) (transformer nil))
"Define interactive helm-org-rifle command, which will run the appropriate hooks.
Helm will be called with vars in LET bound."
Expand All @@ -375,7 +374,7 @@ Helm will be called with vars in LET bound."
(helm :sources ,sources)))
(run-hooks 'helm-org-rifle-after-command-hook))))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle "helm-org-rifle" nil t)
(helm-org-rifle-define-command
"" ()
"This is my rifle. There are many like it, but this one is mine.
Expand Down Expand Up @@ -406,13 +405,13 @@ So be it, until victory is ours and there is no enemy, but
peace!"
:sources (helm-org-rifle-get-sources-for-open-buffers))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-current-buffer "helm-org-rifle" nil t)
(helm-org-rifle-define-command
"current-buffer" ()
"Rifle through the current buffer."
:sources (helm-org-rifle-get-source-for-buffer (current-buffer)))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-files "helm-org-rifle" nil t)
(helm-org-rifle-define-command
"files" (&optional files)
"Rifle through FILES, where FILES is a list of paths to Org files.
Expand All @@ -439,14 +438,14 @@ are searched; they are not filtered with
(when (helm-attr 'new-buffer source)
(kill-buffer (helm-attr 'buffer source))))))))))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-sort-by-latest-timestamp "helm-org-rifle" nil t)
(helm-org-rifle-define-command
"sort-by-latest-timestamp" ()
"Rifle through open buffers, sorted by latest timestamp."
:transformer 'helm-org-rifle-transformer-sort-by-latest-timestamp
:sources (helm-org-rifle-get-sources-for-open-buffers))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-current-buffer-sort-by-latest-timestamp "helm-org-rifle" nil t)
(helm-org-rifle-define-command
"current-buffer-sort-by-latest-timestamp" ()
"Rifle through the current buffer, sorted by latest timestamp."
Expand Down Expand Up @@ -493,7 +492,6 @@ Files in DIRECTORIES are filtered using

;;;;;; Occur commands

;;;###autoload
(cl-defmacro helm-org-rifle-define-occur-command (name args docstring &key buffers files directories preface)
"Define `helm-org-rifle-occur' command to search BUFFERS."
`(defun ,(intern (concat "helm-org-rifle-occur"
Expand Down Expand Up @@ -538,43 +536,44 @@ Files in DIRECTORIES are filtered using
(helm-org-rifle-occur-begin buffers-collected))))
(run-hooks 'helm-org-rifle-after-command-hook))))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-occur "helm-org-rifle" nil t)
(helm-org-rifle-define-occur-command
nil ()
"Search all Org buffers, showing results in an occur-like, persistent buffer."
:buffers (--remove (string= helm-org-rifle-occur-results-buffer-name (buffer-name it))
(-select 'helm-org-rifle-buffer-visible-p
(org-buffer-list nil t))))
;;;###autoload

;;;###autoload (autoload 'helm-org-rifle-occur-current-buffer "helm-org-rifle" nil t)
(helm-org-rifle-define-occur-command
"current-buffer" ()
"Search current buffer, showing results in an occur-like, persistent buffer."
:buffers (list (current-buffer)))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-occur-directories "helm-org-rifle" nil t)
(helm-org-rifle-define-occur-command
"directories" (&optional directories)
"Search files in DIRECTORIES, showing results in an occur-like, persistent buffer.
Files are opened if necessary, and the resulting buffers are left open."
:directories (or directories
(helm-read-file-name "Directories: " :marked-candidates t)))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-occur-files "helm-org-rifle" nil t)
(helm-org-rifle-define-occur-command
"files" (&optional files)
"Search FILES, showing results in an occur-like, persistent buffer.
Files are opened if necessary, and the resulting buffers are left open."
:files (or files
(helm-read-file-name "Files: " :marked-candidates t)))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-occur-agenda-files "helm-org-rifle" nil t)
(helm-org-rifle-define-occur-command
"agenda-files" ()
"Search Org agenda files, showing results in an occur-like, persistent buffer.
Files are opened if necessary, and the resulting buffers are left open."
:files (org-agenda-files))

;;;###autoload
;;;###autoload (autoload 'helm-org-rifle-occur-org-directory "helm-org-rifle" nil t)
(helm-org-rifle-define-occur-command
"org-directory" ()
"Search files in `org-directory', showing results in an occur-like, persistent buffer.
Expand Down

0 comments on commit cd875b7

Please sign in to comment.