README-elpa (8244B)
1 ━━━━━━━━━━━━━━━━━ 2 DENOTE-MENU 3 4 Mohamed Suliman 5 sulimanm@tcd.ie 6 ━━━━━━━━━━━━━━━━━ 7 8 9 10 11 12 1 Overview 13 ══════════ 14 15 `denote-menu' provides an interface for viewing your denote files that 16 goes beyond using the standard `dired' emacs command to view your 17 `denote-directory'. Using dired is a fine method for viewing your 18 denote files (among other things), however denote’s file naming scheme 19 tends to clutters the buffer with hyphens and underscores. This 20 package aims to declutter your view of your files by making it easy to 21 view the 3 main components of denote files, that is their timestamp, 22 title, and keywords. Derived from the builtin `tabulated-list-mode', 23 the `*Denote*' buffer that is created with the `list-denotes' command 24 is visually similar to that created by commands like `list-packages' 25 and `list-processes', and provides methods to filter the denote files 26 that are shown, as well as exporting to dired with the denote files 27 that are currently shown for them to be operated upon further. In this 28 way, `denote-menu' adheres to the core tenants of the denote package 29 itself. 30 31 It is /predictable/ as it makes use of existing emacs functionality to 32 display files in a tabulated way similar to the package menu. It is 33 /composable/, integrating well with other emacs packages (denote, in 34 this case) and builtin functionality, opting to not reinvent the wheel 35 as to how the data is displayed. The scope of this package is narrow: 36 displaying and filtering denote files in a visually appealing and 37 intuitive manner. `denote-menu' is also /flexible/ and /hackable/, 38 providing a simple API to create your own filters, and integrates well 39 with dired by providing the `denote-menu-export-to-dired' command, 40 which allows for further action on denote files beyond just viewing 41 and filtering them. 42 43 <file:screenshots/screenshot.png> 44 45 46 2 Installation 47 ══════════════ 48 49 `denote-menu' is available on the GNU ELPA package archive. To 50 install, simply run 51 52 ┌──── 53 │ M-x package-install RET denote-menu RET 54 └──── 55 56 57 This package requires Denote `v1.2.0' or above. 58 59 60 3 Usage 61 ═══════ 62 63 Assuming that you have `denote-directory' set to a directory that has 64 denote files, simply run `M-x list-denotes' to open the `*Denote*' 65 buffer. You will be presented with a tabulated list of your denote 66 files whose filenames match the `denote-menu-initial-regex' regular 67 expression. By default this is set to match all denote files in the 68 `denote-directory'. 69 70 The tabulated list includes 3 columns, one for the timestamp, title, 71 and keywords of each denote file. The timestamp column includes a 72 button that when followed will open the corresponding denote file 73 using `find-file'. 74 75 76 3.1 Filtering by regular expression 77 ─────────────────────────────────── 78 79 To filter the denote files shown by a regular expression, run `M-x 80 denote-menu-filter'. This will prompt for a regular expression and 81 will update the buffer to list only those denote files whose filenames 82 match. Running `denote-menu-filter' again will further filter down the 83 list. This is akin to running `% m' inside a `dired' buffer. 84 85 86 3.2 Filtering by keyword 87 ──────────────────────── 88 89 To filter the denote files shown to those that are tagged with 90 specific keywords, run `M-x denote-menu-filter-by-keyword'. This 91 command will prompt for a list of comma separated keywords (with 92 completion) and filter the list to those denote files that are tagged 93 with at least one of the inputted keywords. 94 95 96 3.3 Defining your own filters 97 ───────────────────────────── 98 99 There are two ways to define your own filters: 100 1. Write an interactive function that sets `denote-menu-current-regex' 101 to be a regular expression that matches your desired set of denote 102 files, and then calls `denote-menu-update-entries'. For example, if 103 I would like to a filter that filters out those denote files that 104 were not tagged with the “biblio” keyword, I would add the 105 following to my emacs configuration: 106 ┌──── 107 │ (defun my/denote-menu-filter-biblio-only () 108 │ (interactive) 109 │ (setq denote-menu-current-regex "_biblio") 110 │ (denote-menu-update-entries)) 111 └──── 112 113 2. Write an interactive function that sets `tabulated-list-entries' to 114 a be a function that maps each desired denote file path to an entry 115 using `denote-menu--path-to-entry' function, and calls 116 `revert-buffer'. For example, if the variable 117 `my-matching-denote-paths' contains a list of file paths of the 118 desired denote files, then your filter function would look 119 something like the following: 120 ┌──── 121 │ (defun my/denote-menu-filter-custom () 122 │ (interactive) 123 │ (let ((my-matching-denote-paths '("/home/namilus/zettelkasten/20220719T135304--this-is-my-first-note__meta.org"))) 124 │ (setq tabulated-list-entries (lambda () (mapcar #'denote-menu--path-to-entry my-matching-denote-paths))) 125 │ (revert-buffer))) 126 └──── 127 128 129 3.4 Clearing filters 130 ──────────────────── 131 132 To clear the filters and revert back to the 133 `denote-menu-initial-regex', run `M-x denote-menu-clear-filters'. 134 135 136 3.5 Exporting to `dired' 137 ──────────────────────── 138 139 Adhering to the tenets of predictability and composability, 140 `denote-menu' provides the command `denote-menu-export-to-dired' to 141 allow further action on these files that is permitted in dired e.g 142 copying, moving, compressing, etc. We do not reinvent the wheel here 143 but instead defer to what already exists. 144 145 When in the `*Denote*' buffer running `M-x 146 denote-menu-export-to-dired' will open a `dired' buffer in the same 147 window with those denote files that were displayed in the `*Denote*' 148 buffer already marked. 149 150 151 4 Sample configuration 152 ══════════════════════ 153 154 The user options for `denote-menu' are: 155 `denote-menu-date-column-width' 156 A number value for the width of the date column. Defaults to 17. 157 `denote-menu-title-column-width' 158 A number value for the width of the title column. Defaults to 159 85. 160 `denote-menu-keywords-column-width' 161 A number value for the width of the keywords column. Defaults to 162 30. This value is irrelevant as it is the final column and will 163 take up the remaining width of the buffer. 164 `denote-menu-show-file-type' 165 If non-nil, appends the file type of the current denote file to 166 the title. 167 `denote-menu-initial-regex' 168 A string that is the regular expression that is used to 169 initially populate the `*Denote*' buffer with matching 170 entries. This could allow for potential workflows such as having 171 a dedicated buffer to display your journal denote files (e.g 172 those tagged with the “journal” keyword), etc. Defaults to the 173 `.' regular expression. 174 `denote-menu-action' 175 A function that takes as argument the current denote file path 176 and performs an action on it. Defaults to `(lambda (path) 177 (find-file path))'. This function is then called whenever the 178 button in the timestamp column is followed. 179 180 181 A sample user configuration is given below that sets appropriate 182 keybindings for the commands described in the previous section: 183 184 ┌──── 185 │ (require 'denote-menu) 186 │ 187 │ (global-set-key (kbd "C-c z") #'list-denotes) 188 │ 189 │ (define-key denote-menu-mode-map (kbd "c") #'denote-menu-clear-filters) 190 │ (define-key denote-menu-mode-map (kbd "/ r") #'denote-menu-filter) 191 │ (define-key denote-menu-mode-map (kbd "/ k") #'denote-menu-filter-by-keyword) 192 │ (define-key denote-menu-mode-map (kbd "e") #'denote-menu-export-to-dired) 193 └────