Sort bookmarks alphabetically
What happened?
I have my bookmarks list sorted by alphabet and am used to this, I know "by heart" which entry is where.
In Helm the entrys are sorted by "newest on top" or via helm-adaptive.
I wish there were a way to sort them by alphabet. Vanilla emacs has the option:
(setq bookmark-sort-flag t)
Helm doesn't seem to use it. Could you please implement an option like that into Helm for helm-bookmarks and helm-filtered-bookmarks? It would help me a lot.
How to reproduce?
Show bookmarks in helm-mini via
(setq helm-mini-default-sources '(helm-source-recentf
helm-source-bookmarks
helm-source-files-in-current-dir
helm-source-buffers-list))
But also when calling M-x helm-bookmarks or M-x helm-filtered-bookmarks.
Helm Version
Melpa or NonGnuElpa
Emacs Version
Emacs-27.1
OS
GNU/Linux
Relevant backtrace (if possible)
No response
Minimal configuration
- [X] I agree using a minimal configuration
TitusMu @.***> writes:
What happened?
I have my bookmarks list sorted by alphabet and am used to this, I know "by heart" which entry is where.
In Helm the entrys are sorted by "newest on top" or via helm-adaptive.
I wish there were a way to sort them by alphabet. Vanilla emacs has the option:
(setq bookmark-sort-flag t)
Helm doesn't seem to use it. Could you please implement an option like that into Helm for helm-bookmarks and helm-filtered-bookmarks? It would help me a lot.
Thanks for your request.
Now M-x helm-bookmarks and its source helm-source-bookmarks use emacs-vanilla bookmark sorting i.e. they obey bookmark-sort-flag (at least they should, let me know if it works fine for you).
For helm-filtered-bookmarks you have now to set the new variable
helm-bookmark-default-sort-method to 'native in your init file to have
the effect expected (it default to 'adaptive).
Note that if you modify helm-bookmark-default-sort-method during your emacs session, change will take effect only when Emacs restart.
-- Thierry
Thank you so much!
Although I am not getting it to work yet. In my normal emacs environment (Doom), both helm-bookmarks and helm-filtered-bookmarks show the bookmarks by newest first, while *Bookmark List* shows them sorted alphabetically.
M-x describe-variable gives me:
helm-bookmark-default-sort-method’s value is ‘native’
bookmark-sort-flag is a variable defined in ‘bookmark.el’.
Its value is t
Regrettably, I cannot load helm into the minimal configuration. I tried with emacs -q and M-x load-file, but I get the error:
Loading /home/titus/.emacs.d/.local/straight/repos/helm/helm.el (source)...
eval-buffer: Cannot open load file: Datei oder Verzeichnis nicht gefunden, async
(("Datei oder Verzeichnis nicht gefunden" means "file or directory not found".))
I am relatively new to emacs and no programmer, so I am quite sure it is a mistake I make.
TitusMu @.***> writes:
Thank you so much!
Although I am not getting it to work yet. In my normal emacs environment (Doom), both helm-bookmarks and helm-filtered-bookmarks show the bookmarks by newest first, while Bookmark List shows them sorted alphabetically.
M-x describe-variable gives me:
helm-bookmark-default-sort-method’s value is ‘native’
How did you set (and when or at which point) helm-bookmark-default-sort-method ?
bookmark-sort-flag is a variable defined in ‘bookmark.el’. Its value is t
So M-x helm-bookmarks should sort by names, no?
Regrettably, I cannot load helm into the minimal configuration.
- cd to your elpa/helm directory or wherever helm is installed.
- ./emacs-helm.sh
For convenience (unless you have installed helm from source with make, in this case it is already done) you can create a symlink emacs-helm.sh => ~/bin/helm (for example if "~/bin" is in your PATH).
Loading /home/titus/.emacs.d/.local/straight/repos/helm/helm.el (source)... eval-buffer: Cannot open load file: Datei oder Verzeichnis nicht gefunden, async
(("Datei oder Verzeichnis nicht gefunden" means "file or directory not found".))
Yes, that's normal Emacs at this point doesn't know where async package is unless you have installed all your packages in "site-lisp" (eval load-path from emacs -q to see what I mean).
I am relatively new to emacs and no programmer, so I am quite sure it is a mistake I make.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.**>
-- Thierry
Note also that only helm-filtered-bookmarks obey helm-bookmark-default-sort-method.

The docstring of bookmark-sort-flag is not very good, see the one of bookmark-maybe-sort-alist which explains better bookmark-sort-flag.
Note the difference between helm adaptive and native sorting of bookmark (obeying bookmark-sort-flag). The former is sorting by recentest access while the other is sorting by recentest set (or alpha) which is quite different.
Looks great on your side (the screenhots)!
How did you set (and when or at which point) helm-bookmark-default-sort-method ?
I tried both, first I set it in my config.el:
(setq helm-bookmark-default-sort-method 'native)
This worked to set it (if describe-variable tells the truth). But I also tried to set it at the end of my init.el. This did the same.
Still, at my side the bookmarks are not yet sorted alphabetically.
Now I am trying hard to get helm running in minimal configuration, as a newbie I first had to find out how to do git and make and make install ... :)
I did it with:
EMACSLOADPATH="/home/titus/.emacs.d/.local/straight/build-27.1/async/:" make
Still, when I start ./emacs-helm.sh, Emacs gives the error:
Cannot open load file: Datei oder Verzeichnis nicht gefunden, async
(file or directory not found)
I copied the whole async-Folder from /home/titus/.emacs.d/.local/straight/build-27.1/async/ to /usr/local/share/emacs/site-lisp/, but that didn't help, probably it's stupid. After that I removed the async-Folder and did:
git clone https://github.com/jwiegley/emacs-async
and make and make install. Now we have it at:
/usr/local/share/emacs/site-lisp/emacs-async/
But starting ./emacs-helm.sh in the Helm folder still, when emacs starts, gives the error, that it didn't find async. Is emacs-async the wrong module?
So sorry for all these newbie-problems that probably don't even have to do with Helm at all.
TitusMu @.***> writes:
Looks great on your side (the screenhots)!
How did you set (and when or at which point) helm-bookmark-default-sort-method ?I tried both, first I set it in my config.el:
(setq helm-bookmark-default-sort-method 'native)
Ok, this has no effect until the sources are rebuilded, use either this:
(customize-set-variable 'helm-bookmark-default-sort-method 'native)
or the customize interface to set this variable, like this custom will rebuild the sources for you ;-).
This worked to set it (if describe-variable tells the truth).
Yes but the :set function from the defcustom didn't run because you used setq.
But I also tried to set it at the end of my init.el. This did the same.
Still, at my side the bookmarks are not yet sorted alphabetically.
Now I am trying hard to get helm running in minimal configuration, as a newbie I first had to find out how to do git and make and make install ... :)
If you install from source i.e. with git+make+make install you have first to uninstall both async and helm and then install async from source with make && make install and same for helm.
I did it with:
EMACSLOADPATH="/home/titus/.emacs.d/.local/straight/build-27.1/async/:" make
Still, when I start ./emacs-helm.sh, Emacs gives the error:
Cannot open load file: Datei oder Verzeichnis nicht gefunden, async (file or directory not found)
Hmm, I think emacs-helm.sh can't resolve "/home/titus/.emacs.d/.local/straight/build-27.1/" for some reasons, I will try to fix this, problem is that I constantly have to solve these problems due to exotic emacs configurations more an more frequent, doom, spacemacs, straight, quelpa etc...
I copied the whole async-Folder from /home/titus/.emacs.d/.local/straight/build-27.1/async/ to /usr/local/share/emacs/site-lisp/, but that didn't help, probably it's stupid. After that I removed the async-Folder and did:
git clone https://github.com/jwiegley/emacs-async
and make and make install. Now we have it at:
/usr/local/share/emacs/site-lisp/emacs-async/
But starting ./emacs-helm.sh in the Helm folder still, when emacs starts, gives the error, that it didn't find async.
And now where is helm installed?
Is emacs-async the wrong module?
No it is correct.
-- Thierry
TitusMu @.***> writes:
EMACSLOADPATH="/home/titus/.emacs.d/.local/straight/build-27.1/async/:" make
emacs-helm.sh is looking for straight installation here:
(straight-path (expand-file-name "straight/build/" user-emacs-directory))
which expand here to "/home/thierry/.emacs.d/straight/build/". At the time when I was using straight, it was working. Do you use a special setting for the straight directory so that it expand to "/home/titus/.emacs.d/.local/straight/build-27.1/" ?
Thanks.
-- Thierry
Assuming helm and async are installed by straight (remove all you attempts to install from source), is this patch working?
diff --git a/emacs-helm.sh b/emacs-helm.sh
index c3020ea8..bfd26d9d 100755
--- a/emacs-helm.sh
+++ b/emacs-helm.sh
@@ -182,10 +182,13 @@ cat > $CONF_FILE <<EOF
(pkg-list (and packages
(not (equal packages ""))
(split-string packages ",")))
- (straight-path (expand-file-name "straight/build/" user-emacs-directory))
- (async-path (expand-file-name "straight/build/async" user-emacs-directory))
+ ;; Assume user installed helm and async from straight.
+ (straight-path (file-name-directory
+ (directory-file-name
+ (file-name-directory (file-truename "$0")))))
+ (async-path (expand-file-name "async" straight-path))
(bootstrap-file
- (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
+ (expand-file-name "repos/straight.el/bootstrap.el" (file-name-directory (directory-file-name straight-path))))
(bootstrap-version 5))
(when (file-exists-p bootstrap-file)
(setq default-package-manager 'straight)
Thank you very much! I tried the new emacs-helm.sh. It still wanted async and didn't find it, but then I did
straight-use-package RET helm RET
After that, running emacs-helm.sh the second time, it works just fine from start.
I can imagine what nuisance it must be and how much extra work with Doom and Spacemacs. Thank you for putting up with us anyways, Thierry. (I use Doom.)
Now, thanks to your help, I got minimal configuration to work. And the bookmarks got sorted!
I asked myself why it doesn't work the same in my Doom config, and deleted the bookmark file. Now, starting fresh, it also worked in Emacs Doom, all new bookmarks I was setting are sorted in both *Bookmark List* and helm-bookmarks.
But this only works until I exit emacs and the bookmark file is created. The second time I start, the first bookmarks are still sorted (because they are saved sorted to the bookmark file), but when I add new bookmarks, helm-bookmarks doesn't sort them anymore, only the vanilla bookmark list of emacs shows them alphabetically sorted.
My Bookmarks are saved in:
/home/titus/.emacs.d/.local/etc/bookmarks
While the ones from the minimal configuration are saved in:
/home/titus/.emacs.d/bookmarks
How come Helm stops sorting as soon as there is a bookmark file?
Oh no, and now I checked helm-bookmark-default-sort-method, and the minimal config helm doesn't know this variable. (It is the one starting with: This Emacs is Powered by ‘HELM’. I will try installing it again. When I used straight-use-package RET helm RET it new the variable, only running it further times it seems to forget it.
I don't know what I did wrong. Now, after newly installing Helm, I can start your new emacs-helm.sh as often as I want, it always knoows helm-bookmark-default-sort-method (I just have to call straight-use-package RET helm RET every time at the beginning).
As the minimal configuration doesn't seem to save customized variable settings, it starts every time with the variabe set to "adaptive". But I found out that even with "adaptive" the bookmarks are sorted alphabetically. I wish it worked like this in my real config. Sorry for all the chaos!
TitusMu @.***> writes:
I don't know what I did wrong. Now, after newly installing Helm, I can start your new emacs-helm.sh as often as I want, it always knoows helm-bookmark-default-sort-method (I just have to call straight-use-package RET helm RET every time at the beginning).
You should not have to do this, I am working on it, the last problem remaining is the "build-27.1/" directory, it seems doom is using a special directory for each emacs. Because of this helm doesn't find the bootstrap.el file and fail to load straight. For sure a variable should exists for this but we don't have access to it until emacs starts.
As the minimal configuration doesn't seem to save customized variable settings, it starts every time with the variabe set to "adaptive". But I found out that even with "adaptive" the bookmarks are sorted alphabetically.
Yes, adaptive do nothing until you use (helm-adaptive-mode 1). And even with that there is no sorting initially because helm-adaptive have no infos until you start typing some stuff in minibuffer and jumping to some bookmarks, more you use it, more the sorting will be accurate.
I wish it worked like this in my real config. Sorry for all the chaos!
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.**>
-- Thierry