Variable: treemacs-sorting
treemacs-sorting is a customizable variable defined in
treemacs-customization.el.
Value
alphabetic-asc
Documentation
Indicates how treemacs will sort its files and directories.
Files will still always be shown after directories.
Valid values are:
* alphabetic-asc,
* alphabetic-desc,
* alphabetic-numeric-asc,
* alphabetic-numeric-desc,
* alphabetic-case-insensitive-asc,
* alphabetic-case-insensitive-desc,
* alphabetic-numeric-case-insensitive-asc,
* alphabetic-numeric-case-insensitive-desc,
* size-asc,
* size-desc,
* mod-time-asc,
* mod-time-desc
* a custom function
In the latter case it must be a function that can be passed to sort to sort
absolute filepaths. For an example see treemacs--sort-alphabetic-asc
Note about performance: Treemacs does its best to optimise its performance critical path, it does so by doing as little work as possible and producing as little garbage as possible. Deciding on the order in which its nodes are inserted is a part of this path. As such certain trade-offs need to be accounted far.
In plaintext: some sort settings are much slower than others. Alphabetic sorting (the default) is fastest and causes no additional overhead (even when compared against foregoing sorting altogether).
Modification time sorting takes the middle, being ca. 4x slower than alphabetic. Sorting by size is slowest, being ca. 5-6x slower than alphabetic. It also produces the most garbage, making it more like for you to run into a garbage collection pause.
Lest these numbers scare you off keep in mind that they will likely have little to no effect on your usage of treemacs until you begin frequently refreshing treemacs views containing hundreds or even thousands of nodes.
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-customization.el
(defcustom treemacs-sorting 'alphabetic-asc
"Indicates how treemacs will sort its files and directories.
Files will still always be shown after directories.
Valid values are:
* `alphabetic-asc',
* `alphabetic-desc',
* `alphabetic-numeric-asc',
* `alphabetic-numeric-desc',
* `alphabetic-case-insensitive-asc',
* `alphabetic-case-insensitive-desc',
* `alphabetic-numeric-case-insensitive-asc',
* `alphabetic-numeric-case-insensitive-desc',
* `size-asc',
* `size-desc',
* `mod-time-asc',
* `mod-time-desc'
* a custom function
In the latter case it must be a function that can be passed to `sort' to sort
absolute filepaths. For an example see `treemacs--sort-alphabetic-asc'
Note about performance:
Treemacs does its best to optimise its performance critical path, it does so
by doing as little work as possible and producing as little garbage as possible.
Deciding on the order in which its nodes are inserted is a part of this path.
As such certain trade-offs need to be accounted far.
In plaintext: some sort settings are much slower than others. Alphabetic
sorting (the default) is fastest and causes no additional overhead (even when
compared against foregoing sorting altogether).
Modification time sorting takes the middle, being ca. 4x slower than
alphabetic. Sorting by size is slowest, being ca. 5-6x slower than alphabetic.
It also produces the most garbage, making it more like for you to run into a
garbage collection pause.
Lest these numbers scare you off keep in mind that they will likely have little
to no effect on your usage of treemacs until you begin frequently refreshing
treemacs views containing hundreds or even thousands of nodes."
:type '(choice (const alphabetic-asc)
(const alphabetic-desc)
(const alphabetic-numeric-asc)
(const alphabetic-numeric-desc)
(const alphabetic-case-insensitive-asc)
(const alphabetic-case-insensitive-desc)
(const alphabetic-numeric-case-insensitive-asc)
(const alphabetic-numeric-case-insensitive-desc)
(const size-asc)
(const size-desc)
(const mod-time-asc)
(const mod-time-desc))
:group 'treemacs)