alphapapa / org-recent-headings

Go to recently used Org headings
56 stars 4 forks source link

Making sorting optional #16

Open akirak opened 3 years ago

akirak commented 3 years ago

At present, helm-org-recent-headings-source is defined as follows in helm-org-recent-headings.el:

(defvar helm-org-recent-headings-source
  (helm-build-sync-source " Recent Org headings"
    :candidates (lambda ()
                  (org-recent-headings--prepare-list)
                  org-recent-headings-list)
    :candidate-number-limit 'org-recent-headings-candidate-number-limit
    :candidate-transformer 'helm-org-recent-headings--truncate-candidates
    ;; FIXME: If `helm-org-recent-headings-map' is changed after this `defvar' is
    ;; evaluated, the keymap used in the source is not changed, which is very confusing
    ;; for users (including myself).  Maybe we should build the source at runtime.
    :keymap helm-org-recent-headings-map
    :action (helm-make-actions
             "Show entry (default function)" 'org-recent-headings--show-entry-default
             "Show entry in real buffer" 'org-recent-headings--show-entry-direct
             "Show entry in indirect buffer" 'org-recent-headings--show-entry-indirect
             "Remove entry" 'helm-org-recent-headings-remove-entries
             "Bookmark heading" 'org-recent-headings--bookmark-entry))
  "Helm source for `org-recent-headings'.")

org-recent-headings--prepare-list sorts the history by frecency. I personally don't like this behavior, and I'd prefer history ordered by recency, without duplicates.

I also want to add some custom actions to this Helm source.

For now, I will copy this source code and define my own Helm source for recent headings to suit my own needs. It might be better to allow the user to define his/her own sorting mechanism, e.g. using prescient. In the end, I may end up with your implementation, but I don't know if frecency is a good idea here.

alphapapa commented 3 years ago

Okay, well, if you want to propose a PR to make sorting more flexible, I'm open to the idea. For me, frecency is exactly what I want, because it acts much like a Web browser's address bar completion, letting me quickly access headings that I use frequently without having to bookmark each one.