├── LICENSE ├── README.md ├── init.org └── init.el /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Blaine Mooers and the University of Oklahoma Board of Regents 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Version](https://img.shields.io/static/v1?label=dsw-2024-org-mode-init&message=0.5&color=brightcolor) 2 | [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) 3 | 4 | # Emacs configuration file for writing research papers in Org-mode 5 | 6 | This configuration file accompanies the 2024 November 22 Oklahoma Data Science Workshop meeting. 7 | The `init.org` version of the `init.el` file is rendered nicely by GitHub. 8 | 9 | This configuration file, `init.el`, focuses on writing research papers in org-mode in `GNU Emacs`. 10 | It was meant to use default settings, but I included packages I enjoy using (e.g., treemacs, undo-tree, vertico, marginalia, citar, yasnippets, pdf-tools). 11 | It includes `company` for autocompletion. 12 | It uses `lsp-mode` instead of eglot. 13 | Uses James Stoup's fonts for org-mode. 14 | It includes custom functions to make it easier to work in Org Mode. 15 | For example, `C-c t` captures a thought and adds it as a todo item to the bottom of the TODO list in the selected logfile. The keybinding `C-c r` is used to first select the target log file . 16 | The configuration uses straight and use-package for package management. 17 | 18 | After my talk on November 22, I made the following enhancements: 19 | 20 | - Added copilot.el. You will need a GitHub token to use it. It can get in the way when writing prose and make the cursor jump to unintended places so use with caution. 21 | - Added org-roam, org-ref, citar-org-roam, org-roam-bibtex, and org-roam-bibtex - citar integration. (Org-ref is used to add bibtex entries to the bibliography by pasting the DOI into the buffer. Citar is used to insert the citations and generate the bibliography. Org-roam-bibtex is used to search for bibtex entries in the bibliography. Org-roam-bibtex - citar is used to insert the citations and generate the bibliography in org-roam.) 22 | - Moved the handling of org-roam capture notes to citar. 23 | - Added the faster `jinx` package for spell checking (use right mouse button to select a correction or to add a term to your personal library). 24 | - Added a function to open a bibNotes.org file in ~/bibNotes that is renamed after the citekey that the cursor is sitting on for the annotated bibliography. The entries in the main org file of the annotated bibliography 25 | - Added a function to open the log file in the current directory and place the cursor at line above the headline with restart-here tag. This is where you make the next daily entry. 26 | - Added wc-count-mode for displaying the new words added on the modeline. 27 | - Added the markdown package to support the editing of README.md files that you might edit for private GitHub repositories or Codeberg repositories where you store your manuscript file. Added functions to support the moving of items in a list up and down with M- abd M-. 28 | - Added the overlooked package orderless for enhanced searching of command in the mini-buffer. 29 | 30 | 31 | It should give the new user a rich enough experience to suppress their urge to add new packages and break their configuration. 32 | 33 | ## Prerequisite 34 | GNU Emacs only. I am using version 29.4 compiled from source code. It should work with versions 30 and 31. It may work with older versions. 35 | 36 | ## Installation 37 | Download and move the init.el file to your Emacs configuration folder (e.g., ~/e29fewpackages). 38 | 39 | ## Usage example 40 | Start emacs with the init-directory flag pointing to your Emacs configuration folder. 41 | 42 | ```bash 43 | /Applications/Emacs29.4.app/Contents/MacOS/Emacs --init-directory ~/e29fewpackages --debug-init 44 | ``` 45 | 46 | ## Notes 47 | 48 | - Give the Emacs several minutes to install about 60 packages during startup. 49 | - Startup time will be about 10 seconds in future startups. 50 | - If commented out three packages that require customized file paths. Edit these to suit your workflow. 51 | - I map the above command to the zsh alias `e29f`. 52 | ```bash 53 | alias ef='/Applications/Emacs29.4.app/Contents/MacOS/Emacs --init-directory ~/e29fewpackages --debug-init' 54 | ``` 55 | 56 | ## Improved usage with alias 57 | 58 | I use `e29f +500 logXXXX.org` to open `logXXXX.org` in the current directory on startup and to place the cursor at line 500. 59 | 60 | 61 | ## Enhance your editing experience by using the Emacs server 62 | 63 | Enter `M-x server-start' in a Emacs GUI session to start the Emacs server. 64 | Then you can open instantly another instance of the same session in another terminal window by using the following alias. 65 | 66 | ```bash 67 | alias efmxc='/Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient29 -c' 68 | ``` 69 | 70 | Use it by entering `efmxc filename.org`. 71 | 72 | You may into trouble if another Emacs server is running. 73 | Kill it with the following command. 74 | The `-s` option is for the name of the server. 75 | 76 | ```bash 77 | alias efk="/Applications/Emacs29.4.app/Contents/MacOS/bin/emacsclient29 -s ef29server --eval '(kill-emacs)'" 78 | ``` 79 | 80 | The same opened buffers will be present. 81 | Enter `C-x #` to close a file and close that instance of the server. 82 | The emacslient makee Emacs more useful for short edits where Neovim or Textmate might otherwise be used due to their fast startup times. 83 | 84 | 85 | 86 | 87 | ## Update history 88 | 89 | |Version | Changes | Date | 90 | |:------------|:----------------------------------------------------------------------------------------------------------------------------------------|:------------------| 91 | | Version 0.1 | Added badges, funding, and update table. Initial commit. | 2024 November 10 | 92 | | Version 0.2 | Minor edits | 2024 November 22 | 93 | | Version 0.3 | Add init file in org-mode format for rendering by GitHub. | 2024 November 25 | 94 | | Version 0.4 | Updated the init.el file with org-roam, org-ref, citar, org-roam-bibtex, and org-roam-bibtex - citar integration. Added a function to open bibNotes.org in ~/bibNotes for the annotated bibliography. This should complete the tool chain. | 2024 November 26 | 95 | | Version 0.5 | Updated init.el file to specify path to texlive. | 2024 November 30 | 96 | 97 | ## Acknowledgments 98 | ### Sources of funding 99 | 100 | - NIH: R01 CA242845 101 | - NIH: R01 AI088011 102 | - NIH: P30 CA225520 (PI: R. Mannel) 103 | - NIH: P20 GM103640 and P30 GM145423 (PI: A. West) 104 | -------------------------------------------------------------------------------- /init.org: -------------------------------------------------------------------------------- 1 | #+TITLE: Emacs Configuration 2 | #+AUTHOR: Your Name 3 | 4 | * The org-mode verson of the ~few packages~ init.el configuration available at https://github.com/MooersLab/dsw-2024-org-mode-init. 5 | - The number of semicolons indicates the headline level. 6 | - The combination of a semicolon and a percent sign denotes a comment to be converted to prose in the org file. 7 | - The lines without semicolons in the left margin wind up in code blocks. 8 | 9 | - I use the bash command alias e29f='/Applications/Emacs29.4.app/Contents/MacOS/Emacs --init-directory ~/e29fewpackages --debug-init' 10 | 11 | ** The top section sets up the package management software and must come first. 12 | #+BEGIN_SRC emacs-lisp 13 | (setq user-emacs-directory "~/e29fewpackages/") 14 | (defvar bootstrap-version) 15 | (let ((bootstrap-file 16 | (expand-file-name 17 | "straight/repos/straight.el/bootstrap.el" 18 | (or (bound-and-true-p straight-base-dir) 19 | user-emacs-directory))) 20 | (bootstrap-version 7)) 21 | (unless (file-exists-p bootstrap-file) 22 | (with-current-buffer 23 | (url-retrieve-synchronously 24 | "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 25 | 'silent 'inhibit-cookies) 26 | (goto-char (point-max)) 27 | (eval-print-last-sexp))) 28 | (load bootstrap-file nil 'nomessage)) 29 | (straight-use-package 'org) 30 | (setq package-enable-at-startup nil) 31 | (use-package use-package) 32 | (setq straight-use-package-by-default t) 33 | #+END_SRC 34 | Messages printed to the messages buffer aid in locating bugs in the config file because the bug is somewhere beyond the last message. 35 | #+BEGIN_SRC emacs-lisp 36 | (message "Finished straight package manager configuration.") 37 | #+END_SRC 38 | # ***************************** Global Settings section *********************************************** 39 | ** Global Settings 40 | The order of the remaining content of the intial.org does not matter but I like to divide it into settings, user-defined functions, and packages. 41 | #+BEGIN_SRC emacs-lisp 42 | (message "Start global configuration.") 43 | #+END_SRC 44 | *** Enable mouse in terminal Emacs (emacs -nw) 45 | #+BEGIN_SRC emacs-lisp 46 | (when (eq window-system nil) 47 | (xterm-mouse-mode t)) 48 | #+END_SRC 49 | *** Minibuffer history keybindings 50 | The calling up of a previously issued command in the minibuffer with ~M-p~ saves times. 51 | #+BEGIN_SRC emacs-lisp 52 | (autoload 'edit-server-maybe-dehtmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 53 | (autoload 'edit-server-maybe-htmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 54 | (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer) 55 | (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer) 56 | (define-key minibuffer-local-map (kbd "M-p") 'previous-complete-history-element) 57 | (define-key minibuffer-local-map (kbd "M-n") 'next-complete-history-element) 58 | (define-key minibuffer-local-map (kbd "") 'previous-complete-history-element) 59 | (define-key minibuffer-local-map (kbd "") 'next-complete-history-element) 60 | #+END_SRC 61 | *** Bibtex configuration 62 | #+BEGIN_SRC emacs-lisp 63 | (defconst blaine/bib-libraries (list "/Users/blaine/Documents/global.bib")) 64 | #+END_SRC 65 | *** For retina displays on Macs 66 | TCombined with emacs-mac, this gives good PDF quality for [[https://www.aidanscannell.com/post/setting-up-an-emacs-playground-on-mac/][retina display]]. 67 | #+BEGIN_SRC emacs-lisp 68 | (setq pdf-view-use-scaling t) 69 | #+END_SRC 70 | *** PDF default page width behavior 71 | #+BEGIN_SRC emacs-lisp 72 | (setq-default pdf-view-display-size 'fit-page) 73 | #+END_SRC 74 | *** Custom key sequences. 75 | Delete trailing whitespaces on lines. 76 | #+BEGIN_SRC emacs-lisp 77 | (global-set-key (kbd "C-c d") 'delete-trailing-whitespace) 78 | #+END_SRC 79 | *** display line numbers. Need with s-l. 80 | #+BEGIN_SRC emacs-lisp 81 | (global-display-line-numbers-mode) 82 | #+END_SRC 83 | *** highlight current line 84 | This feature aids finding the cursor's current position. 85 | #+BEGIN_SRC emacs-lisp 86 | (global-hl-line-mode +1) 87 | (set-face-background hl-line-face "wheat1") 88 | (set-face-attribute 'mode-line nil :height 180) 89 | #+END_SRC 90 | *** Shell configuration 91 | Let Emacs know which shell that you are using. 92 | #+BEGIN_SRC emacs-lisp 93 | (use-package exec-path-from-shell 94 | :straight t 95 | :init 96 | (setenv "SHELL" "/opt/local/bin/zsh") 97 | :if (memq window-system '(mac ns x)) 98 | :config 99 | (setq exec-path-from-shell-variables '("PATH" "GOPATH" "PYTHONPATH")) 100 | (exec-path-from-shell-initialize)) 101 | #+END_SRC 102 | *** Set size of the starting Window 103 | I like a wider window. Setting it initially saves an operation. 104 | #+BEGIN_SRC emacs-lisp 105 | (setq initial-frame-alist '((top . 1) 106 | (left . 450) 107 | (width . 101) 108 | (height . 90))) 109 | #+END_SRC 110 | *** Setting modifier keys 111 | ==> adjust here for operating system 112 | See this [[http://ergoemacs.org/emacs/emacs_hyper_super_keys.html][ for more information.]] 113 | set keys for Apple keyboard, for emacs in OS X 114 | Source http://xahlee.info/emacs/emacs/emacs_hyper_super_keys.html 115 | Seems to only work in the GUI mode. 116 | #+BEGIN_SRC emacs-lisp 117 | (setq mac-command-modifier 'meta) ; make cmd key do Meta 118 | (setq mac-option-modifier 'super) ; make option key do Super. 119 | (setq mac-control-modifier 'control) ; make Control key do Control 120 | (setq mac-function-modifier 'hyper) ; make Fn key do Hyper. Only works on Apple produced keyboards. 121 | (setq mac-right-command-modifier 'hyper) 122 | #+END_SRC 123 | *** Move cursor to place at last save 124 | Enable save-place-mode 125 | #+BEGIN_SRC emacs-lisp 126 | (save-place-mode 1) 127 | #+END_SRC 128 | Optionally specify the file to save cursor positions 129 | #+BEGIN_SRC emacs-lisp 130 | (setq save-place-file "~/e29fewpackages/places") 131 | #+END_SRC 132 | *** Setting section is finished 133 | #+BEGIN_SRC emacs-lisp 134 | (message "Finished settings configuration.") 135 | #+END_SRC 136 | # ***************************** User-defined functions section *********************************************** 137 | ** Start user-defined functions section 138 | #+BEGIN_SRC emacs-lisp 139 | (message "User defined functions in alphabetical order.") 140 | #+END_SRC 141 | *** create-org-table-with-caption 142 | This interactive function prompts the user for the number of rows, columns, and caption of the table. 143 | #+BEGIN_SRC emacs-lisp 144 | (defun create-org-table-with-caption () 145 | "This interactive function prompts the user for the number of rows. columns, and the caption of the table." 146 | (interactive) 147 | (let ((rows (read-number "Enter the number of rows: ")) 148 | (cols (read-number "Enter the number of columns: ")) 149 | (label (read-string "Enter the table label: ")) 150 | (caption (read-string "Enter the table's caption: "))) 151 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 152 | (insert (format "#+NAME: %s\n" label)) 153 | (insert "|") 154 | (dotimes (_ cols) 155 | (insert "----+")) 156 | (insert "\n|") 157 | (dotimes (col cols) 158 | (insert (format " %c |" (+ ?A col)))) 159 | (insert "\n|") 160 | (dotimes (_ cols) 161 | (insert "----+")) 162 | (insert "\n") 163 | (dotimes (_ rows) 164 | (insert "|") 165 | (dotimes (_ cols) 166 | (insert " |")) 167 | (insert "\n")) 168 | (insert "|") 169 | (dotimes (_ cols) 170 | (insert "----+")))) 171 | #+END_SRC 172 | *** find file and go to line number 173 | Interactively enter the file name and line number in the minibuffer 174 | #+BEGIN_SRC emacs-lisp 175 | (defun find-file-at-line (file line) 176 | "Open FILE on LINE." 177 | (interactive "fFile: \nNLine: \n") 178 | (find-file file) 179 | (goto-line line)) 180 | 181 | #+END_SRC 182 | *** ffap: find file at point 183 | https://unix.stackexchange.com/questions/691444/how-do-i-open-a-file-at-specific-line-in-a-running-emacs 184 | have ffap pick up line number and goto-line 185 | found on emacswiki : https://www.emacswiki.org/emacs/FindFileAtPoint#h5o-6 186 | #+BEGIN_SRC emacs-lisp 187 | (defvar ffap-file-at-point-line-number nil 188 | "Variable to hold line number from the last `ffap-file-at-point' call.") 189 | (defadvice ffap-file-at-point (after ffap-store-line-number activate) 190 | "Search `ffap-string-at-point' for a line number pattern and 191 | save it in `ffap-file-at-point-line-number' variable." 192 | (let* ((string (ffap-string-at-point)) ;; string/name definition copied from `ffap-string-at-point' 193 | (name 194 | (or (condition-case nil 195 | (and (not (string-match "//" string)) ; foo.com://bar 196 | (substitute-in-file-name string)) 197 | (error nil)) 198 | string)) 199 | (line-number-string 200 | (and (string-match ":[0-9]+" name) 201 | (substring name (1+ (match-beginning 0)) (match-end 0)))) 202 | (line-number 203 | (and line-number-string 204 | (string-to-number line-number-string)))) 205 | (if (and line-number (> line-number 0)) 206 | (setq ffap-file-at-point-line-number line-number) 207 | (setq ffap-file-at-point-line-number nil)))) 208 | 209 | (defadvice find-file-at-point (after ffap-goto-line-number activate) 210 | "If `ffap-file-at-point-line-number' is non-nil goto this line." 211 | (when ffap-file-at-point-line-number 212 | (goto-line ffap-file-at-point-line-number) 213 | (setq ffap-file-at-point-line-number nil))) 214 | #+END_SRC 215 | *** insert-org-captioned-figure 216 | The function prompts the user for the image file path and name, the label, and the caption. 217 | #+BEGIN_SRC emacs-lisp 218 | (defun insert-org-captioned-figure () 219 | "Insert a captioned figure in Org-mode." 220 | (interactive) 221 | (let ((image-name (read-string "Enter the image file path: ")) 222 | (label (read-string "Enter the figure label: ")) 223 | (caption (read-string "Enter the figure caption: "))) 224 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 225 | (insert (format "#+NAME: %s\n" label)) 226 | (insert (format "[[file:%s]]\n" image-name)))) 227 | #+END_SRC 228 | *** Convert a selected latex list of items to a org-mode list 229 | To use this function, select the region containing the LaTeX list and run: 230 | `M-x latex-to-org-list-region` 231 | #+BEGIN_SRC emacs-lisp 232 | (defun latex-to-org-list-region (start end) 233 | "Convert a LaTeX itemize list in the region to an Org-mode list." 234 | (interactive "r") 235 | (save-excursion 236 | (goto-char start) 237 | (while (re-search-forward "\\\\item" end t) 238 | (replace-match "-")))) 239 | #+END_SRC 240 | 241 | 242 | *** Open the Daily Log headline while keeping the other headline closed. 243 | #+BEGIN_SRC emacs-lisp 244 | (defun org-open-specific-headline (headline) 245 | "Open the specific top-level HEADLINE while keeping others closed." 246 | (goto-char (point-min)) 247 | (org-overview) 248 | (if (re-search-forward (format "^\\* %s" (regexp-quote headline)) nil t) 249 | (org-show-children 3) 250 | (message "Headline not found"))) 251 | (defun my-org-mode-setup () 252 | "Custom setup for Org mode." 253 | (org-open-specific-headline "Daily Log")) 254 | (add-hook 'org-mode-hook 'my-org-mode-setup) 255 | ;;; Moves cursor to headline with the restart tag. 256 | ;% Waits for the my-org-mode-setup function to run first. 257 | 258 | (defun my-open-log-file-and-move-above-tag () 259 | "If the current buffer's file name starts with 'log', move the cursor above a second-level headline with a specific tag." 260 | (let ((tag "restart-here")) 261 | (when (and buffer-file-name 262 | (string-prefix-p "log" (file-name-nondirectory buffer-file-name))) 263 | (goto-char (point-min)) 264 | (if (re-search-forward (format "^\\*\\* .*:%s:" tag) nil t) 265 | (forward-line -1) 266 | (message "Tag not found"))))) 267 | ;defun org-open-specific-headline (headline) 268 | ; "Open the specific top-level HEADLINE while keeping others closed. 269 | ;hen move the cursor to the line above the second-level headline with the tag." 270 | ; (goto-char (point-min)) 271 | ; (org-overview) 272 | ; (if (re-search-forward (format "^\\* %s" (regexp-quote headline)) nil t) 273 | ; (progn 274 | ; (org-show-children 3) 275 | ; (when (re-search-forward "^\\*\\* .*:restart-here:" nil t) 276 | ; (beginning-of-line) 277 | ; (forward-line -1))) 278 | ; (message "Headline not found"))) 279 | #+END_SRC 280 | *** my-delayed-org-setup 281 | #+BEGIN_SRC emacs-lisp 282 | (defun my-delayed-org-setup () 283 | "Run my-org-mode-setup and then my-open-log-file-and-move-above-tag." 284 | (my-org-mode-setup) 285 | (run-at-time "0.1 sec" nil 'my-open-log-file-and-move-above-tag)) 286 | (add-hook 'org-mode-hook 'my-delayed-org-setup) 287 | #+END_SRC 288 | 289 | *** Open a file and move to a headline with a specific tag 290 | The default tag is restart-here. 291 | Example usage: 292 | `(open-org-file-and-move-to-tag "~/path/to/your/file.org" "your-tag")` 293 | #+BEGIN_SRC emacs-lisp 294 | (defun open-org-file-and-move-to-tag (file &optional tag) 295 | "Open an Org file and move the cursor below a headline with a specific TAG. 296 | If TAG is not provided, use a hardcoded default tag. 297 | You have have to adjust the headline level in the funciton. 298 | The regular expression ^\\*\\* .*:%s: is used to search for second-level headlines (those starting with **) with the specified tag." 299 | (interactive "fOrg file: \nsTag (leave empty for default): ") 300 | (let ((tag (if (string= tag "") "restart-here" tag))) 301 | (find-file file) 302 | (goto-char (point-min)) 303 | (if (re-search-forward (format "^\\*\\* .*:%s:" tag) nil t) 304 | (org-end-of-subtree) 305 | (message "Tag not found")))) 306 | #+END_SRC 307 | *** Play a YouTube video with mpv 308 | You insert the YouTube url in the minibufffer. 309 | You have to install mpv with a package manager and another binary package. 310 | `sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl` 311 | `sudo chmod a+rx /usr/local/bin/youtube-dl` 312 | #+BEGIN_SRC emacs-lisp 313 | (defun play-youtube-video (url) 314 | "Play a YouTube video with mpv." 315 | (interactive "sYouTube URL: ") 316 | (start-process "mpv" nil "mpv" URL)) 317 | #+END_SRC 318 | *** Protesilous Starvou functions 319 | **** Functions to open popup menu when Emacs server is running 320 | Source: https://www.youtube.com/watch?v=vbWxT8tht9A&list=PL8Bwba5vnQK14z96Gil86pLMDO2GnOhQ6 321 | This function is used to capture notes when Emacs is not open. 322 | This idea could be harness for other purposes. 323 | You will need to map the 324 | #+BEGIN_SRC emacs-lisp 325 | (defun prot-window-delete-popup-frame (&rest _) 326 | "Kill selected selected frame if it has parameter `prot-window-popup-frame'. 327 | Use this function via a hook." 328 | (when (frame-parameter nil 'prot-window-popup-frame) 329 | (delete-frame))) 330 | (defmacro prot-window-define-with-popup-frame (command) 331 | "Define interactive function which calls COMMAND in a new frame. 332 | Make the new frame have the `prot-window-popup-frame' parameter." 333 | `(defun ,(intern (format "prot-window-popup-%s" command)) () 334 | ,(format "Run `%s' in a popup frame with `prot-window-popup-frame' parameter. 335 | Also see `prot-window-delete-popup-frame'." command) 336 | (interactive) 337 | (let ((frame (make-frame '((prot-window-popup-frame . t))))) 338 | (select-frame frame) 339 | (switch-to-buffer " prot-window-hidden-buffer-for-popup-frame") 340 | (condition-case nil 341 | (call-interactively ',command) 342 | ((quit error user-error) 343 | (delete-frame frame)))))) 344 | (declare-function org-capture "org-capture" (&optional goto keys)) 345 | (defvar org-capture-after-finalize-hook) 346 | #+END_SRC 347 | *** ###autoload (autoload 'prot-window-popup-org-capture "prot-window") 348 | #+BEGIN_SRC emacs-lisp 349 | (prot-window-define-with-popup-frame org-capture) 350 | (add-hook 'org-capture-after-finalize-hook #'prot-window-delete-popup-frame) 351 | #+END_SRC 352 | Another popup function for use with the tmr package. 353 | #+BEGIN_SRC emacs-lisp 354 | (declare-function tmr "tmr" (time &optional description acknowledgep)) 355 | (defvar tmr-timer-created-functions) 356 | ;; (autoload 'prot-window-popup-tmr "prot-window") 357 | (prot-window-define-with-popup-frame tmr) 358 | (add-hook 'tmr-timer-created-functions #'prot-window-delete-popup-frame) 359 | #+END_SRC 360 | ***** The emacsclient calls that need ot be bound to system-wide keys 361 | The emacsclient is an Emac version agnostic. 362 | #+BEGIN_SRC bash 363 | `alias oc="emacslient -e '(prot-window-popup-org-capture)'"` 364 | `emacsclient -e '(prot-window-popup-tmr)'` 365 | #+END_SRC 366 | *** Reload the initialization file after editing it in Emacs 367 | #+BEGIN_SRC emacs-lisp 368 | (defun reload-init-e29f () 369 | "Reload the init.el file for e29org. Edit the path to suite your needs." 370 | (interactive) 371 | (load-file "~/e29fewpackages/init.el")) 372 | #+END_SRC 373 | *** Spawn a new shell with the supplied title 374 | #+BEGIN_SRC emacs-lisp 375 | (defun spawn-shell (name) 376 | "Invoke shell test" 377 | (interactive "MName of shell buffer to create: ") 378 | (pop-to-buffer (get-buffer-create (generate-new-buffer-name name))) 379 | (shell (current-buffer)) 380 | (process-send-string nil "echo 'test1'\n") 381 | (process-send-string nil "echo 'test2'\n")) 382 | #+END_SRC 383 | *** Move the cursor to the minibuffer without using the mouse 384 | From video https://www.youtube.com/watch?v=X8c_TrGfYcM&t=15s using Emacs as a multiplexer." 385 | Derived from http://stackoverflow.com/a/4116113/446256. 386 | #+BEGIN_SRC emacs-lisp 387 | (defun switch-to-minibuffer () 388 | "Switch to minibuffer window." 389 | (interactive) 390 | (if (active-minibuffer-window) 391 | (select-window (active-minibuffer-window)) 392 | (error "Minibuffer is not active"))) 393 | (global-set-key "\C-cm" 'switch-to-minibuffer) ;; Bind to `C-c m' for minibuffer. 394 | (message "End of user-defined functions.") 395 | #+END_SRC 396 | 397 | # ***************************** Package configuration section *********************************************** 398 | 399 | ** Package configuration section 400 | #+BEGIN_SRC emacs-lisp 401 | (message "Start package configurations in alphabetical order by package name.") 402 | (message "Start A package configurations") 403 | #+END_SRC 404 | *** A 405 | **** AUCTeX 406 | This is the more advanced LaTeX. 407 | Emacs has native LaTeX support that AUCTeX is an alternative to. 408 | #+BEGIN_SRC emacs-lisp 409 | (use-package auctex 410 | :straight t 411 | :defer t) 412 | (message "Start C package configurations") 413 | #+END_SRC 414 | *** C 415 | **** Citar 416 | Citar is a bibliographic management system that is an alternative to org-ref. 417 | Citar can operate in tex and org file whereas org-ref is limited to org-mode files. 418 | #+BEGIN_SRC emacs-lisp 419 | (use-package citar 420 | :straight t 421 | :bind (("C-c b" . citar-insert-citation) 422 | :map minibuffer-local-map 423 | ("M-b" . citar-insert-preset)) 424 | :custom 425 | (citar-bibliography '("/Users/blaine/Documents/global.bib")) 426 | (citar-library-paths '("/Users/blaine/0papersLabeled") '("/Users/blaine/0booksUnlabeled")) 427 | (citar-library-file-extensions '("pdf" "epub")) 428 | :hook 429 | #+END_SRC 430 | **** enable autocompletion in buffer of citekeys 431 | #+BEGIN_SRC emacs-lisp 432 | (LaTeX-mode . citar-capf-setup) 433 | (org-mode . citar-capf-setup)) 434 | #+END_SRC 435 | **** company-box 436 | ***** formats the options delivered by the company autocompletion system 437 | #+BEGIN_SRC emacs-lisp 438 | (use-package company-box 439 | :straight t 440 | :config 441 | (setq company-box-max-candidates 50 442 | company-frontends '(company-tng-frontend company-box-frontend) 443 | company-box-icons-alist 'company-box-icons-all-the-icons)) 444 | (with-eval-after-load 'company 445 | (define-key company-active-map 446 | (kbd "TAB") 447 | #'company-complete-common-or-cycle) 448 | (define-key company-active-map 449 | (kbd "") 450 | (lambda () 451 | (interactive) 452 | (company-complete-common-or-cycle -1)))) 453 | (with-eval-after-load 'company 454 | (define-key company-active-map (kbd "M-.") #'company-show-location) 455 | (define-key company-active-map (kbd "RET") nil)) 456 | #+END_SRC 457 | **** Company Configuration 458 | Source: https://github.com/Exafunction/codeium.el 459 | #+BEGIN_SRC emacs-lisp 460 | (use-package company 461 | :straight t 462 | :defer 0.1 463 | :hook ((emacs-lisp-mode . (lambda () 464 | (setq-local company-backends '(company-elisp)))) 465 | (emacs-lisp-mode . company-mode)) 466 | :config 467 | (global-company-mode t) 468 | (company-tng-configure-default) ; restore old tab behavior 469 | (setq-default 470 | company-idle-delay 0.05 471 | company-require-match nil 472 | company-minimum-prefix-length 1 473 | company-frontends '(company-preview-frontend) 474 | company-frontends '(company-pseudo-tooltip-frontend company-preview-frontend) 475 | )) 476 | (message "Finished C package configurations") 477 | (message "Started L packages configurations") 478 | #+END_SRC 479 | *** L 480 | **** lsp-mode 481 | This mode is required to be able to use other lsp modes. 482 | #+BEGIN_SRC emacs-lisp 483 | (use-package lsp-mode 484 | :straight t 485 | :commands (lsp lsp-deferred) 486 | :bind (:map lsp-mode-map 487 | ("C-c d" . lsp-describe-thing-at-point) 488 | ("C-c a" . lsp-execute-code-action)) 489 | :bind-keymap ("C-c l" . lsp-command-map) 490 | :hook ((latex-mode . lsp-deferred) 491 | (lsp-mode . lsp-enable-which-key-integration)) 492 | :config 493 | (lsp-enable-which-key-integration t) 494 | (setq lsp-headerline-breadcrumb-enable nil)) 495 | #+END_SRC 496 | **** lsp-latex 497 | #+BEGIN_SRC emacs-lisp 498 | (use-package lsp-latex 499 | :straight t 500 | :after lsp-mode 501 | :hook (latex-mode . lsp-latex-enable)) 502 | #+END_SRC 503 | **** lsp-ltex (the languagetool lsp server) 504 | #+BEGIN_SRC emacs-lisp 505 | (use-package lsp-ltex 506 | :straight t 507 | :after lsp-mode 508 | :hook ((text-mode . lsp) 509 | (latex-mode . lsp) 510 | (org-mode . lsp)) 511 | :config 512 | (setq lsp-ltex-language "en-US") 513 | :init 514 | (setq lsp-ltex-version "16.0.0")) 515 | #+END_SRC 516 | **** lsp-ui 517 | #+BEGIN_SRC emacs-lisp 518 | (use-package lsp-ui 519 | :straight t 520 | :commands lsp-ui-mode) 521 | #+END_SRC 522 | **** lsp-treemacs 523 | #+BEGIN_SRC emacs-lisp 524 | (use-package lsp-treemacs 525 | :straight t 526 | :commands lsp-treemacs-errors-list) 527 | (message "Finished L package configurations") 528 | (message "Start M package configurations") 529 | #+END_SRC 530 | *** M 531 | **** Marginalia Configuration 532 | This package produces a transient list of optional commands. 533 | #+BEGIN_SRC emacs-lisp 534 | (use-package marginalia 535 | :straight (marginalia :type git :host github :repo "minad/marginalia") 536 | :config 537 | (marginalia-mode)) 538 | (customize-set-variable 'marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) 539 | (marginalia-mode 1) 540 | #+END_SRC 541 | **** Math-preview that is mode agnostic 542 | Uses MathJaX. 543 | You have to download and install the bindary 544 | #+BEGIN_SRC emacs-lisp 545 | (use-package math-preview 546 | :straight t 547 | :custom (math-preview-command "/Users/blaine/.nvm/versions/node/v22.4.0/lib/node_modules/math-preview/math-preview.js"))s 548 | (message "Finished M packages configurations") 549 | 550 | (message "Start O package configurations") 551 | #+END_SRC 552 | *** O 553 | **** Org-agenda 554 | This can be complex to configure. 555 | #+BEGIN_SRC emacs-lisp 556 | (setq org-agenda-start-with-log-mode t) 557 | (setq org-log-done 'time) 558 | (setq org-log-into-drawer t) 559 | #+END_SRC 560 | ***** Follow links 561 | #+BEGIN_SRC emacs-lisp 562 | (setq org-return-follows-link t) 563 | #+END_SRC 564 | ***** Treat *.org files as org-mode files 565 | #+BEGIN_SRC emacs-lisp 566 | (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) 567 | #+END_SRC 568 | ***** Hide the emphasis markers so you just see bold text as BOLD-TEXT and not *BOLD-TEXT* 569 | #+BEGIN_SRC emacs-lisp 570 | (setq org-hide-emphasis-markers t) 571 | #+END_SRC 572 | ***** Stoup's fonts for org 573 | These settings have been added to the customization section. 574 | They can only be called once in an init.el file. 575 | #+BEGIN_COMMENT 576 | (let* ((variable-tuple 577 | (cond ((x-list-fonts "ETBembo") '(:font "ETBembo")) 578 | ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro")) 579 | ((x-list-fonts "Lucida Grande") '(:font "Lucida Grande")) 580 | ((x-list-fonts "Verdana") '(:font "Verdana")) 581 | ((x-family-fonts "Sans Serif") '(:family "Sans Serif")) 582 | (nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro.")))) 583 | (base-font-color (face-foreground 'default nil 'default)) 584 | (headline `(:inherit default :weight bold :foreground ,base-font-color))) 585 | 586 | (custom-theme-set-faces 587 | 'user 588 | `(org-level-8 ((t (,@headline ,@variable-tuple)))) 589 | `(org-level-7 ((t (,@headline ,@variable-tuple)))) 590 | `(org-level-6 ((t (,@headline ,@variable-tuple)))) 591 | `(org-level-5 ((t (,@headline ,@variable-tuple)))) 592 | `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.1)))) 593 | `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.2)))) 594 | `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.3)))) 595 | `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.5)))) 596 | `(org-document-title ((t (,@headline ,@variable-tuple :height 1.6 :underline nil)))))) 597 | #+END_COMMENT 598 | 599 | ***** Org-agenda key-bindings 600 | #+BEGIN_SRC emacs-lisp 601 | (define-key global-map "\C-ca" 'org-agenda) 602 | (setq org-log-done t) 603 | (define-key global-map "\C-cc" 'org-capture) 604 | (define-key global-map "\C-cl" 'org-store-link) 605 | (global-set-key (kbd "C-c v") 'org-refile) 606 | #+END_SRC 607 | Note that I have more capture commands below. 608 | #+BEGIN_SRC emacs-lisp 609 | (setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA") 610 | #+END_SRC 611 | ***** Source of TODO keywords read into org-agenda 612 | #+BEGIN_SRC emacs-lisp 613 | (setq org-agenda-files '("/Users/blaine/.notes" 614 | "/Users/blaine/gtd/tasks/JournalArticles.org" 615 | "/Users/blaine/0573CrystalDetectionMeasurement/log0573.org" 616 | "/Users/blaine/0598tenRulesWritingLog/cb/log0598tsrWritingLog.org" 617 | "/Users/blaine/gtd/tasks/Proposals.org" 618 | "/Users/blaine/1019NIHemofat/cb/log1019.org" 619 | "/Users/blaine/gtd/tasks/Books.org" 620 | "/Users/blaine/gtd/tasks/Talks.org" 621 | "/Users/blaine/gtd/tasks/Posters.org" 622 | "/Users/blaine/gtd/tasks/ManuscriptReviews.org" 623 | "/Users/blaine/gtd/tasks/Private.org" 624 | "/Users/blaine/gtd/tasks/Service.org" 625 | "/Users/blaine/gtd/tasks/Teaching.org" 626 | "/Users/blaine/gtd/tasks/Workshops.org" 627 | "/Users/blaine/gtd/tasks/springsem24.org" 628 | "/Users/blaine/gtd/tasks/summersem24.org" 629 | "/Users/blaine/gtd/tasks/fallsem24.org")) 630 | #+END_SRC 631 | ***** Order of TODO keywords 632 | Cycle through these keywords with shift right or left arrows. 633 | #+BEGIN_SRC emacs-lisp 634 | (setq org-todo-keywords 635 | '((sequence "TODO(t)" "PLANNING(p)" "IN-PROGRESS(i@/!)" "WAITING(w!)" "CAL(a)" "PROJ(j)" "|" "DONE(d!)" "SOMEDAY(s!)" "CANCELLED(c!)" ))) 636 | #+END_SRC 637 | ***** TODO keyword colors 638 | #+BEGIN_SRC emacs-lisp 639 | (setq org-todo-keyword-faces 640 | '( 641 | ("TODO" . (:foreground "Red" :weight bold)) 642 | ("PLANNING" . (:foreground "DeepPink" :weight bold)) 643 | ("IN-PROGRESS" . (:foreground "Cyan" :weight bold)) 644 | ("WAITING" . (:foreground "DarkOrange" :weight bold)) 645 | ("CAL" . (:foreground "GoldenOrange" :weight bold)) 646 | ("PROJ" . (:foreground "LimeGreen" :weight bold)) 647 | ("DONE" . (:foreground "LimeGreen" :weight bold)) 648 | ("SOMEDAY" . (:foreground "LimeGreen" :weight bold)) 649 | ("CANCELLED" . (:foreground "LightGray" :weight bold)) 650 | )) 651 | #+END_SRC 652 | ***** Press C-c r to select the log file from the list of log files for insert todos with C-c t 653 | The function will then search for the heading with the specified tag and append the TODO item at the bottom of the TODO list under that heading. 654 | #+BEGIN_SRC emacs-lisp 655 | (setq my-org-refile-directories '( 656 | ("/Users/blaine/gtd/tasks/JournalArticles.org" :maxlevel . 3) 657 | ("/Users/blaine/gtd/tasks/Proposals.org" :maxlevel . 3) 658 | ("/Users/blaine/0598tenRulesWritingLog/cb/log0598tsrWritingLog.org" :maxlevel . 3) 659 | )) 660 | #+END_SRC 661 | ****** Writing project log files as refile targets 662 | The TODOs are at the 3rd headline level. 663 | #+BEGIN_SRC emacs-lisp 664 | (setq my-org-refile-targets '( 665 | ("/Users/blaine/0573CrystalDetectionMeasurement/log0573.org" :maxlevel . 3) 666 | ("/Users/blaine/0598tenRulesWritingLog/cb/log0598tsrWritingLog.org" :maxlevel . 3) 667 | ("/Users/blaine/1019NIHemofat/cb/log1019.org" :maxlevel . 3) 668 | )) 669 | 670 | (defun my-select-org-refile-target () 671 | "Prompt for an org refile target from a list of directories." 672 | (interactive) 673 | (let ((target (completing-read "Select refile target: " my-org-refile-targets))) 674 | (setq my-org-refile-targets `((,target :maxlevel . 3))))) 675 | 676 | (setq org-refile-use-outline-path 'file) 677 | (global-set-key (kbd "C-c r") 'my-select-org-refile-target) 678 | #+END_SRC 679 | ****** Append TODO item at bottom of TODO list in writing project log file. 680 | I like to use project ID number and 'do' at the tag. 681 | #+BEGIN_SRC emacs-lisp 682 | (defun my-append-todo-to-heading (tag todo-text) 683 | "Append TODO-TEXT to the bottom of a TODO list under a heading with TAG. Enter the tag without the flanking colons." 684 | (interactive "sTag: \nsTODO: ") 685 | (save-excursion 686 | (goto-char (point-min)) 687 | (if (re-search-forward (format "^\*+ .* :%s:" tag) nil t) 688 | (progn 689 | (org-end-of-subtree t t) 690 | (insert (format "*** TODO %s \n" todo-text))) 691 | (message "Heading with tag %s not found" tag)))) 692 | (global-set-key (kbd "C-c t") 'my-append-todo-to-heading) 693 | (message "Finished refile target configuration.") 694 | #+END_SRC 695 | ***** Customized agenda views 696 | These are my customized agenda views by project. 697 | The letter is the last parameter. 698 | For example, enter ~C-c a b~ and then enter 402 at the prompt to list all active tasks related to 402 tasks. 699 | 700 | I learned about this approach [[https://tlestang.github.io/blog/keeping-track-of-tasks-and-projects-using-emacs-and-org-mode.html][here]]. 701 | 702 | The CATEGORY keyword resides inside of a Properties drawer. 703 | The drawers are usually closed. 704 | I am having trouble opening my drawers in may org files. 705 | In addition, I do not want to have to add a drawer to each TODO. 706 | 707 | I am loving Tags now. 708 | I may switch to using Tags because they are visible in org files. 709 | I tried and they are not leading to the expect list of TODOs in org-agenda. 710 | I am stumped. 711 | 712 | In the meantime, enter ~C-c \~ inside JournalArticles.org to narrow the focus to the list of TODOs or enter ~C-c i b~ to get an indirect buffer. 713 | #+BEGIN_SRC emacs-lisp 714 | (setq org-agenda-custom-commands 715 | '( 716 | ("b" 717 | "List of all active 1019 tasks." 718 | tags-todo 719 | "1019\"/TODO|INITIATED|WAITING") 720 | ("c" 721 | "List of all active 523 RNA-drug crystallization review paper tasks." 722 | tags-todo 723 | "CATEGORY=\"523\"/TODO|INITIATED|WAITING") 724 | ("d" 725 | "List of all active 0527CrystalDetectionByAI tasks." 726 | tags-todo 727 | "CATEGORY=\"527\"/TODO|INITIATED|WAITING") 728 | ("e" 729 | "List of all active 0032RNA32merEditingSite tasks." 730 | tags-todo 731 | "CATEGORY=\"32\"/TODO|INITIATED|WAITING") 732 | 733 | ("l" 734 | "List of all active 0598tenRulesWritingProjectLog tasks." 735 | tags-todo 736 | "CATEGORY=\"598\"/TODO|INITIATED|WAITING") 737 | ("e" 738 | "List of all active 0495emofat4mx tasks." 739 | tags-todo 740 | "CATEGORY=\"495\"/TODO|INITIATED|WAITING") 741 | ("r" 742 | "List of all active 0466ReproDSD tasks." 743 | tags-todo 744 | "CATEGORY=\"515\"/TODO|INITIATED|WAITING") 745 | ("s" 746 | "List of all active 0515CrystallizationSupports tasks." 747 | tags-todo 748 | "CATEGORY=\"515\"/TODO|INITIATED|WAITING") 749 | ("P" 750 | "List of all projects" 751 | tags 752 | "LEVEL=2/PROJ"))) 753 | (message "Finished org-agenda custum command configuration.") 754 | (message "Fnished O package configurations") 755 | 756 | (message "Start P package configurations") 757 | #+END_SRC 758 | *** P 759 | **** pdf-tools 760 | Emacs has a built-in DocView package that can display PDFs but it is not as versatile as pdf-tools. 761 | You will likely by prompted to run pdf-tools-install to compile it. 762 | It is needed to be able to annotate PDF from inside Emacs. 763 | I have not gotten that far. 764 | #+BEGIN_SRC emacs-lisp 765 | (use-package pdf-tools 766 | :straight t 767 | :pin manual ;; manually update 768 | :config 769 | #+END_SRC 770 | *** initialise 771 | #+BEGIN_SRC emacs-lisp 772 | (pdf-tools-install) 773 | #+END_SRC 774 | *** open pdfs scaled to fit width 775 | #+BEGIN_SRC emacs-lisp 776 | (setq-default pdf-view-display-size 'fit-width) 777 | #+END_SRC 778 | *** use normal isearch 779 | #+BEGIN_SRC emacs-lisp 780 | (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward) 781 | :custom 782 | (pdf-annot-activate-created-annotations t "automatically annotate highlights")) 783 | (message "Finished P package configurations.") 784 | 785 | (message "Start S package configurations.") 786 | #+END_SRC 787 | *** S 788 | **** show-key 789 | Conflicts with tmux-pane 790 | #+BEGIN_COMMENT 791 | (straight-use-package 792 | '(showkey :type git :local-repo "~/e29fewpackages/manual-install/showkey")) 793 | (set-face-attribute 'default nil :height 240) 794 | (require 'showkey) 795 | #+END_COMMENT 796 | **** The emacsclient call depends on the daemon or `server-mode' 797 | The emacsclient depends either running the server or a daemon. 798 | The server is easier to manage than the daemon because you will 799 | find to find the daemon and kill it after updating the init.el file. 800 | This package is built-in, so it does not need to be installed by straight. 801 | #+BEGIN_SRC emacs-lisp 802 | (use-package server 803 | :ensure nil 804 | :defer 1 805 | :config 806 | (unless (server-running-p) 807 | (server-start))) 808 | (message "Finished S package configurations.") 809 | 810 | 811 | (message "Start T package configurations.") 812 | #+END_SRC 813 | *** T 814 | **** tmux-pane 815 | #+BEGIN_SRC emacs-lisp 816 | (use-package tmux-pane 817 | :straight (tmux-pane :type git :host github :repo "laishulu/emacs-tmux-pane")) 818 | #+END_SRC 819 | **** treemacs 820 | Provides sidebar access to contents of the treemacs project directory 821 | #+BEGIN_SRC emacs-lisp 822 | (use-package treemacs 823 | :straight t 824 | :defer t 825 | :init 826 | (with-eval-after-load 'winum 827 | (define-key winum-keymap (kbd "M-0") #'treemacs-select-window)) 828 | :config 829 | (progn 830 | (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) 831 | treemacs-deferred-git-apply-delay 0.5 832 | treemacs-directory-name-transformer #'identity 833 | treemacs-display-in-side-window t 834 | treemacs-eldoc-display 'simple 835 | treemacs-file-event-delay 2000 836 | treemacs-file-extension-regex treemacs-last-period-regex-value 837 | treemacs-file-follow-delay 0.2 838 | treemacs-file-name-transformer #'identity 839 | treemacs-follow-after-init t 840 | treemacs-expand-after-init t 841 | treemacs-find-workspace-method 'find-for-file-or-pick-first 842 | treemacs-git-command-pipe "" 843 | treemacs-goto-tag-strategy 'refetch-index 844 | treemacs-header-scroll-indicators '(nil . "^^^^^^") 845 | treemacs-hide-dot-git-directory t 846 | treemacs-indentation 2 847 | treemacs-indentation-string " " 848 | treemacs-is-never-other-window nil 849 | treemacs-max-git-entries 5000 850 | treemacs-missing-project-action 'ask 851 | treemacs-move-files-by-mouse-dragging t 852 | treemacs-move-forward-on-expand nil 853 | treemacs-no-png-images nil 854 | treemacs-no-delete-other-windows t 855 | treemacs-project-follow-cleanup nil 856 | treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) 857 | treemacs-position 'left 858 | treemacs-read-string-input 'from-child-frame 859 | treemacs-recenter-distance 0.1 860 | treemacs-recenter-after-file-follow nil 861 | treemacs-recenter-after-tag-follow nil 862 | treemacs-recenter-after-project-jump 'always 863 | treemacs-recenter-after-project-expand 'on-distance 864 | treemacs-litter-directories '("/node_modules" "/.venv" "/.cask") 865 | treemacs-project-follow-into-home nil 866 | treemacs-show-cursor nil 867 | treemacs-show-hidden-files t 868 | treemacs-silent-filewatch nil 869 | treemacs-silent-refresh nil 870 | treemacs-sorting 'alphabetic-asc 871 | treemacs-select-when-already-in-treemacs 'move-back 872 | treemacs-space-between-root-nodes t 873 | treemacs-tag-follow-cleanup t 874 | treemacs-tag-follow-delay 1.5 875 | treemacs-text-scale nil 876 | treemacs-user-mode-line-format nil 877 | treemacs-user-header-line-format nil 878 | treemacs-wide-toggle-width 70 879 | treemacs-width 35 880 | treemacs-width-increment 1 881 | treemacs-width-is-initially-locked t 882 | treemacs-workspace-switch-cleanup nil) 883 | (treemacs-resize-icons 44) 884 | (treemacs-follow-mode t) 885 | (treemacs-filewatch-mode t) 886 | (treemacs-fringe-indicator-mode 'always) 887 | (when treemacs-python-executable 888 | (treemacs-git-commit-diff-mode t)) 889 | (pcase (cons (not (null (executable-find "git"))) 890 | (not (null treemacs-python-executable))) 891 | (`(t . t) 892 | (treemacs-git-mode 'deferred)) 893 | (`(t . _) 894 | (treemacs-git-mode 'simple))) 895 | (treemacs-hide-gitignored-files-mode nil)) 896 | :bind 897 | (:map global-map 898 | ("M-0" . treemacs-select-window) 899 | ("C-x t 1" . treemacs-delete-other-windows) 900 | ("C-x t t" . treemacs) 901 | ("C-x t d" . treemacs-select-directory) 902 | ("C-x t B" . treemacs-bookmark) 903 | ("C-x t C-t" . treemacs-find-file) 904 | ("C-x t M-t" . treemacs-find-tag))) 905 | #+END_SRC 906 | The default width and height of the icons is 22 pixels. If you are 907 | using a Hi-DPI display, uncomment this to double the icon size. 908 | 909 | **** treemacs-protjectile 910 | #+BEGIN_SRC emacs-lisp 911 | (use-package treemacs-projectile 912 | :after (treemacs projectile) 913 | :straight t) 914 | #+END_SRC 915 | **** treemacs-icons-dired 916 | #+BEGIN_SRC emacs-lisp 917 | (use-package treemacs-icons-dired 918 | :hook (dired-mode . treemacs-icons-dired-enable-once) 919 | :straight t) 920 | #+END_SRC 921 | **** treemacs-perspective 922 | treemacs-perspective if you use perspective.el vs. persp-mode 923 | #+BEGIN_SRC emacs-lisp 924 | (use-package treemacs-persp 925 | :after (treemacs persp-mode) ;;or perspective vs. persp-mode 926 | :straight t 927 | :config (treemacs-set-scope-type 'Perspectives)) 928 | #+END_SRC 929 | **** treemacs start on boot 930 | #+BEGIN_SRC emacs-lisp 931 | (treemacs-start-on-boot) 932 | (message "Finished T package configurations.") 933 | 934 | (message "Start U package configurations.") 935 | #+END_SRC 936 | *** U 937 | **** undo-tree 938 | The displayed undo tree is very helpful. 939 | #+BEGIN_SRC emacs-lisp 940 | (use-package undo-tree 941 | :straight t 942 | :config 943 | (global-undo-tree-mode 1)) 944 | (message "Finished U package configurations.") 945 | 946 | (message "Start V package configurations.") 947 | #+END_SRC 948 | *** V 949 | **** vterm 950 | One of five terminal type available in Emacs. 951 | See https://github.com/akermu/emacs-libvterm for configuration of init.el and .zshrc 952 | #+BEGIN_SRC emacs-lisp 953 | (use-package vterm 954 | :straight t) 955 | (define-key vterm-mode-map (kbd "C-q") #'vterm-send-next-key) 956 | #+END_SRC 957 | **** vertico 958 | #+BEGIN_SRC emacs-lisp 959 | (use-package vertico 960 | :straight t 961 | :init 962 | (vertico-mode) 963 | #+END_SRC 964 | **** Different scroll margin 965 | **** (setq vertico-scroll-margin 0) 966 | **** Show more candidates 967 | #+BEGIN_SRC emacs-lisp 968 | (setq vertico-count 20) 969 | #+END_SRC 970 | **** Grow and shrink the Vertico minibuffer 971 | #+BEGIN_SRC emacs-lisp 972 | (setq vertico-resize t) 973 | #+END_SRC 974 | **** Optionally enable cycling for `vertico-next' and `vertico-previous'. 975 | #+BEGIN_SRC emacs-lisp 976 | (setq vertico-cycle t)) 977 | (message "Finished V package configurations.") 978 | 979 | (message "Start package configurations W") 980 | (message "Finished W package configurations.") 981 | #+END_SRC 982 | *** Y 983 | #+BEGIN_SRC emacs-lisp 984 | (message "Start package configurations Y") 985 | #+END_SRC 986 | **** yasnippet 987 | The popular snippet creator and manager package, 988 | #+BEGIN_SRC emacs-lisp 989 | (use-package yasnippet 990 | :straight t 991 | :config 992 | (yas-global-mode 1)) 993 | (global-set-key "\C-o" 'yas-expand) 994 | (global-set-key "\C-c y i" 'yas-insert-snippet) 995 | (global-set-key "\C-c y n" 'yas-new-snippet) 996 | #+END_SRC 997 | **** A cool hydra for finding snippets at point. Invoke with C-c y. 998 | #+BEGIN_SRC emacs-lisp 999 | (use-package hydra 1000 | :straight t 1001 | :defer 2 1002 | :bind ("C-c y" . hydra-yasnippet/body)) 1003 | #+END_SRC 1004 | **** A popup menu for snippet selection 1005 | #+BEGIN_SRC emacs-lisp 1006 | (use-package popup 1007 | :straight t) 1008 | #+END_SRC 1009 | Add some shortcuts in popup menu mode. 1010 | #+BEGIN_SRC emacs-lisp 1011 | (define-key popup-menu-keymap (kbd "M-n") 'popup-next) 1012 | (define-key popup-menu-keymap (kbd "TAB") 'popup-next) 1013 | (define-key popup-menu-keymap (kbd "M-p") 'popup-previous) 1014 | (defun yas/popup-isearch-prompt (prompt choices &optional display-fn) 1015 | (when (featurep 'popup) 1016 | (popup-menu* 1017 | (mapcar 1018 | (lambda (choice) 1019 | (popup-make-item 1020 | (or (and display-fn (funcall display-fn choice)) 1021 | choice) 1022 | :value choice)) 1023 | choices) 1024 | :prompt prompt 1025 | #+END_SRC 1026 | ******* start isearch mode immediately 1027 | #+BEGIN_SRC emacs-lisp 1028 | :isearch t))) 1029 | (setq yas/prompt-functions '(yas/popup-isearch-prompt yas/no-prompt)) 1030 | (message "Finished Y package configurations.") 1031 | 1032 | #+END_SRC 1033 | * Customizations 1034 | Leave these alone. 1035 | #+BEGIN_SRC emacs-lisp 1036 | (message "Start custom set-variables") 1037 | (custom-set-variables 1038 | '(pdf-view-incompatible-modes 1039 | '(linum-mode linum-relative-mode helm-linum-relative-mode nlinum-mode nlinum-hl-mode nlinum-relative-mode yalinum-mode)) 1040 | '(showkey-log-mode t) 1041 | '(weatherline-mode t)) 1042 | (custom-set-faces 1043 | '(org-document-title ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.6 :underline nil)))) 1044 | '(org-level-1 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.5)))) 1045 | '(org-level-2 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.3)))) 1046 | '(org-level-3 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.2)))) 1047 | '(org-level-4 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.1)))) 1048 | '(org-level-5 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande")))) 1049 | '(org-level-6 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande")))) 1050 | '(org-level-7 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande")))) 1051 | '(org-level-8 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande"))))) 1052 | #+END_SRC 1053 | -------------------------------------------------------------------------------- /init.el: -------------------------------------------------------------------------------- 1 | ; The org-mode verson of the ~few packages~ init.el configuration available at https://github.com/MooersLab/dsw-2024-org-mode-init. 2 | ;% - The number of semicolons indicates the headline level. 3 | ;% - The combintatoin of a semicolon and a precent sign denotes a comment to be converted to prose in the org file. 4 | ;% - The lines without semicolons in the left margin wind up in code blocks. 5 | ;% 6 | ;% - I use the bash command alias e29f='/Applications/Emacs29.4.app/Contents/MacOS/Emacs --init-directory ~/e29fewpackages --debug-init' 7 | ;% - Note that you can toogle a fullscreen of Emacs on the Mac with M-F10. 8 | ;; The top section sets up the package management software and must come first. 9 | (setq user-emacs-directory "~/e29fewpackages/") 10 | (defvar bootstrap-version) 11 | (let ((bootstrap-file 12 | (expand-file-name 13 | "straight/repos/straight.el/bootstrap.el" 14 | (or (bound-and-true-p straight-base-dir) 15 | user-emacs-directory))) 16 | (bootstrap-version 7)) 17 | (unless (file-exists-p bootstrap-file) 18 | (with-current-buffer 19 | (url-retrieve-synchronously 20 | "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 21 | 'silent 'inhibit-cookies) 22 | (goto-char (point-max)) 23 | (eval-print-last-sexp))) 24 | (load bootstrap-file nil 'nomessage)) 25 | (straight-use-package 'org) 26 | (setq package-enable-at-startup nil) 27 | (use-package use-package) 28 | (setq straight-use-package-by-default t) 29 | (setq straight-vc-git-default-clone-depth 1) 30 | (setq straight-check-for-modifications '(check-on-save find-when-checking)) 31 | ;% Messages printed to the messages buffer aid in locating bugs in the config file because the bug is somewhere beyond the last message. 32 | (message "Finished straight package manager configuration.") 33 | 34 | ;; Globalsettings 35 | ;% The order of the remaining content of the intial.org does not matter but I like to divide it into settings, user-defined functions, and packages. 36 | (message "Start global configuration.") 37 | ;;; Enable mouse in terminal Emacs (emacs -nw) 38 | (unless (display-graphic-p) 39 | (xterm-mouse-mode 1) 40 | (setq xterm-extra-capabilities '(modifyOtherKeys))) 41 | ;;; Minibuffer history keybindings 42 | ;% The calling up of a previously issued command in the minibuffer with ~M-p~ saves times. 43 | (autoload 'edit-server-maybe-dehtmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 44 | (autoload 'edit-server-maybe-htmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 45 | (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer) 46 | (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer) 47 | (define-key minibuffer-local-map (kbd "M-p") 'previous-complete-history-element) 48 | (define-key minibuffer-local-map (kbd "M-n") 'next-complete-history-element) 49 | (define-key minibuffer-local-map (kbd "") 'previous-complete-history-element) 50 | (define-key minibuffer-local-map (kbd "") 'next-complete-history-element) 51 | ;;; Bibtex configuration 52 | (defconst blaine/bib-libraries (list "/Users/blaine/Documents/global.bib")) 53 | ;;; For retina displays on Macs 54 | ;% TCombined with emacs-mac, this gives good PDF quality for [[https://www.aidanscannell.com/post/setting-up-an-emacs-playground-on-mac/][retina display]]. 55 | (setq pdf-view-use-scaling t) 56 | ;;; PDF default page width behavior 57 | (setq-default pdf-view-display-size 'fit-page) 58 | ;;; Custom key sequences. 59 | ;% Delete trailing whitespaces on lines. 60 | (global-set-key (kbd "C-c d") 'delete-trailing-whitespace) 61 | ;;; display line numbers. Need with s-l. 62 | (global-display-line-numbers-mode) 63 | ;;; highlight current line 64 | ;% This feature aids finding the cursor's current position. 65 | ; (global-hl-line-mode +1) 66 | ; (set-face-background hl-line-face "wheat1") 67 | ;;; Generic highlighting of current line for different background colors 68 | ;; Load hl-line mode 69 | (require 'hl-line) 70 | ;; Set the hl-line face to a neutral color 71 | (set-face-attribute 'hl-line nil :background "Gray70" :foreground 'unspecified) 72 | ;; Enable global hl-line mode 73 | (global-hl-line-mode 1) 74 | ;; Set the region face to an intermediate color 75 | (set-face-attribute 'region nil :background "SlateGray" :foreground "black") 76 | ;; Set the cursor color 77 | (set-cursor-color "yellow") 78 | ;;; Fatten up the mode-line for easeir viewing 79 | (set-face-attribute 'mode-line nil :height 180) 80 | ;;; Set the path to the new Node.js binary 81 | ;% The default Node.js is installed by macports in /opt/local/bin and is outdated. 82 | ;% The newer version is installed by home brew in /usr/local/bin. 83 | ;% Check version of Node found by runing (shell-command-to-string "node -v") 84 | (let ((new-node-path "/opt/homebrew/bin/node")) 85 | (setq exec-path (cons new-node-path exec-path)) 86 | (setenv "PATH" (concat new-node-path ":" (getenv "PATH")))) 87 | ;;; Set size of the starting Window 88 | ;% I like a wider window. Setting it initially saves an operation. 89 | (setq initial-frame-alist '((top . 1) 90 | (left . 450) 91 | (width . 101) 92 | (height . 90))) 93 | ;;; Setting modifier keys 94 | ;% ==> adjust here for operating system 95 | ;% See this [[http://ergoemacs.org/emacs/emacs_hyper_super_keys.html][ for more information.]] 96 | ;% set keys for Apple keyboard, for emacs in OS X 97 | ;% Source http://xahlee.info/emacs/emacs/emacs_hyper_super_keys.html 98 | ;% Seems to only work in the GUI mode. 99 | (setq mac-command-modifier 'meta) ; make cmd key do Meta 100 | (setq mac-option-modifier 'super) ; make option key do Super. 101 | (setq mac-control-modifier 'control) ; make Control key do Control 102 | (setq mac-function-modifier 'hyper) ; make Fn key do Hyper. Only works on Apple produced keyboards. 103 | (setq mac-right-command-modifier 'hyper) 104 | ;;; Move cursor to place at last save 105 | ;% Enable save-place-mode 106 | (save-place-mode 1) 107 | ;% Optionally specify the file to save cursor positions 108 | (setq save-place-file "~/e29fewpackages/places") 109 | (setq server-name "e29f") 110 | (server-start) 111 | ;;; Setting section is finished 112 | (message "Finished settings configuration.") 113 | ;% ***************************** User-defined functions section *********************************************** 114 | ;; Start user-defined functions section 115 | (message "User defined functions in alphabetical order.") 116 | ;% (defun append-to-sqlite-table (db-path table-name pairs) 117 | ;% "Append PAIRS of terms to a two-column TABLE-NAME in the SQLite database at DB-PATH. 118 | ;% PAIRS should be a list of cons cells, where each cons cell is a pair of terms." 119 | ;% (let ((db (emacsql-sqlite db-path))) 120 | ;% (dolist (pair pairs) 121 | ;% (emacsql db 122 | ;% [:insert :into $i1 :values $v2] 123 | ;% table-name 124 | ;% (vector (car pair) (cdr pair)))) 125 | ;% (emacsql-close db))) 126 | ;% ;; Example usage: 127 | ;% (let ((db-path "/path/to/your/database.sqlite") 128 | ;% (table-name 'your_table) 129 | ;% (pairs '((term1 . term2) (term3 . term4) (term5 . term6)))) 130 | ;% (append-to-sqlite-table db-path table-name pairs)) 131 | ;;; convert-init-el-to-org 132 | (defun convert-init-el-to-org (input-file output-file) 133 | "Convert an Emacs init.el file to an Org-mode file." 134 | (with-temp-buffer 135 | (insert-file-contents input-file) 136 | (let ((in-src-block nil)) 137 | (with-temp-file output-file 138 | (insert "#+TITLE: Emacs Configuration\n") 139 | (insert "#+AUTHOR: Blaine Mooers\n") 140 | (insert "#+OPTIONS: toc:nil\n\n") 141 | (goto-char (point-min)) 142 | (while (not (eobp)) 143 | (let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))) 144 | (cond 145 | ;; Match comments and convert them to org-mode headings or prose 146 | ((string-match-p "^\\s-*;%+" line) 147 | (let ((prose (string-trim (replace-regexp-in-string "^\\s-*;%+" "" line)))) 148 | (when in-src-block 149 | (insert "#+END_SRC\n\n") 150 | (setq in-src-block nil)) 151 | (insert (format "%s\n\n" prose)))) 152 | ((string-match-p "^\\s-*;" line) 153 | (let* ((level (length (match-string 0 line))) 154 | (heading (string-trim (replace-regexp-in-string "^\\s-*;+" "" line)))) 155 | (when in-src-block 156 | (insert "#+END_SRC\n\n") 157 | (setq in-src-block nil)) 158 | (insert (format "%s %s\n" (make-string level ?*) heading)))) 159 | (t 160 | (unless in-src-block 161 | (insert "#+BEGIN_SRC emacs-lisp\n") 162 | (setq in-src-block t)) 163 | (insert (format "%s\n" line)))) 164 | (forward-line 1))) 165 | (when in-src-block 166 | (insert "#+END_SRC\n")))))) 167 | ;% Example usage: 168 | ;% (convert-init-el-to-org "~/path/to/init.el" "~/path/to/init.org") 169 | ;;; create-org-table-with-caption 170 | ;% This interactive function prompts the user for the number of rows, columns, and caption of the table. 171 | (defun create-org-table-with-caption () 172 | "This interactive function prompts the user for the number of rows. columns, and the caption of the table." 173 | (interactive) 174 | (let ((rows (read-number "Enter the number of rows: ")) 175 | (cols (read-number "Enter the number of columns: ")) 176 | (label (read-string "Enter the table label: ")) 177 | (caption (read-string "Enter the table's caption: "))) 178 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 179 | (insert (format "#+NAME: %s\n" label)) 180 | (insert "|") 181 | (dotimes (_ cols) 182 | (insert "----+")) 183 | (insert "\n|") 184 | (dotimes (col cols) 185 | (insert (format " %c |" (+ ?A col)))) 186 | (insert "\n|") 187 | (dotimes (_ cols) 188 | (insert "----+")) 189 | (insert "\n") 190 | (dotimes (_ rows) 191 | (insert "|") 192 | (dotimes (_ cols) 193 | (insert " |")) 194 | (insert "\n")) 195 | (insert "|") 196 | (dotimes (_ cols) 197 | (insert "----+")))) 198 | ;;; find file and go to line number 199 | ;% interactively enter the file name and line number in the minibuffer 200 | (defun find-file-at-line (file line) 201 | "Open FILE on LINE." 202 | (interactive "fFile: \nNLine: \n") 203 | (find-file file) 204 | (goto-line line)) 205 | ;;; ffap: find file at point 206 | ;% https://unix.stackexchange.com/questions/691444/how-do-i-open-a-file-at-specific-line-in-a-running-emacs 207 | ;% have ffap pick up line number and goto-line 208 | ;% found on emacswiki : https://www.emacswiki.org/emacs/FindFileAtPoint#h5o-6 209 | (defvar ffap-file-at-point-line-number nil 210 | "Variable to hold line number from the last `ffap-file-at-point' call.") 211 | (defadvice ffap-file-at-point (after ffap-store-line-number activate) 212 | "Search `ffap-string-at-point' for a line number pattern and 213 | save it in `ffap-file-at-point-line-number' variable." 214 | (let* ((string (ffap-string-at-point)) ;; string/name definition copied from `ffap-string-at-point' 215 | (name 216 | (or (condition-case nil 217 | (and (not (string-match "//" string)) ; foo.com://bar 218 | (substitute-in-file-name string)) 219 | (error nil)) 220 | string)) 221 | (line-number-string 222 | (and (string-match ":[0-9]+" name) 223 | (substring name (1+ (match-beginning 0)) (match-end 0)))) 224 | (line-number 225 | (and line-number-string 226 | (string-to-number line-number-string)))) 227 | (if (and line-number (> line-number 0)) 228 | (setq ffap-file-at-point-line-number line-number) 229 | (setq ffap-file-at-point-line-number nil)))) 230 | 231 | (defadvice find-file-at-point (after ffap-goto-line-number activate) 232 | "If `ffap-file-at-point-line-number' is non-nil goto this line." 233 | (when ffap-file-at-point-line-number 234 | (goto-line ffap-file-at-point-line-number) 235 | (setq ffap-file-at-point-line-number nil))) 236 | ;;; insert-org-captioned-figure 237 | ;% The function prompts the user for the image file path and name, the label, and the caption. 238 | (defun insert-org-captioned-figure () 239 | "Insert a captioned figure in Org-mode." 240 | (interactive) 241 | (let ((image-name (read-string "Enter the image file path: ")) 242 | (label (read-string "Enter the figure label: ")) 243 | (caption (read-string "Enter the figure caption: "))) 244 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 245 | (insert (format "#+NAME: %s\n" label)) 246 | (insert (format "[[file:%s]]\n" image-name)))) 247 | ;;; launch-ithoughtsx 248 | ;% This is the best mindmapping software that I have encountered. 249 | (defun launch-ithoughtsx () 250 | "Launch iThoughtsX application." 251 | (interactive) 252 | (shell-command "open -a iThoughtsX")) 253 | (global-set-key (kbd "C-c i") 'launch-ithoughtsx) 254 | ;;; launch-jabref 255 | ;% I favored the simplicity and power of JabRef for mamanging BibTeX entries. 256 | (defun launch-jabref () 257 | "Launch jabRef application." 258 | (interactive) 259 | (shell-command "open -a JabRef")) 260 | (global-set-key (kbd "C-c j") 'launch-jabref) 261 | ;;; launch-timesspent 262 | ;% This is a sqlite database where I track my effort. 263 | (defun launch-timesspent () 264 | "Launch timesspent database." 265 | (interactive) 266 | (shell-command "open /Users/blaine/6003TimeTracking/cb/mytime.db")) 267 | (global-set-key (kbd "C-c e") 'launch-timesspent) 268 | ;;; Convert a selected latex list of items to a org-mode list 269 | ;% To use this function, select the region containing the LaTeX list and run: 270 | ;% M-x latex-to-org-list-region 271 | (defun latex-to-org-list-region (start end) 272 | "Convert a LaTeX itemize list in the region to an Org-mode list." 273 | (interactive "r") 274 | (save-excursion 275 | (goto-char start) 276 | (while (re-search-forward "\\\\item" end t) 277 | (replace-match "-")))) 278 | ;% ;;; Open the Daily Log headline while keeping the other headline closed. 279 | ;% (defun org-open-specific-headline (headline) 280 | ;% "Open the specific top-level HEADLINE while keeping others closed." 281 | ;% (goto-char (point-min)) 282 | ;% (org-overview) 283 | ;% (if (re-search-forward (format "^\\* %s" (regexp-quote headline)) nil t) 284 | ;% (org-show-children 3) 285 | ;% (message "Headline not found"))) 286 | ;% 287 | ;% (defun my-org-mode-setup () 288 | ;% "Custom setup for Org mode." 289 | ;% (org-open-specific-headline "Daily Log")) 290 | ;% (add-hook 'org-mode-hook 'my-org-mode-setup) 291 | ;% 292 | ;% 293 | ;% ;;; Moves cursor to headline with the restart tag. 294 | ;% ;% Waits for the my-org-mode-setup function to run first. 295 | ;% (defun my-open-log-file-and-move-above-tag () 296 | ;% "If the current buffer's file name starts with 'log', move the cursor above a second-level headline with a specific tag." 297 | ;% (let ((tag "restart-here")) 298 | ;% (when (and buffer-file-name 299 | ;% (string-prefix-p "log" (file-name-nondirectory buffer-file-name))) 300 | ;% (goto-char (point-min)) 301 | ;% (if (re-search-forward (format "^\\*\\* .*:%s:" tag) nil t) 302 | ;% (forward-line -1) 303 | ;% (message "Tag not found"))))) 304 | ;% 305 | ;% ;defun org-open-specific-headline (headline) 306 | ;% ; "Open the specific top-level HEADLINE while keeping others closed. 307 | ;% ;hen move the cursor to the line above the second-level headline with the tag." 308 | ;% ; (goto-char (point-min)) 309 | ;% ; (org-overview) 310 | ;% ; (if (re-search-forward (format "^\\* %s" (regexp-quote headline)) nil t) 311 | ;% ; (progn 312 | ;% ; (org-show-children 3) 313 | ;% ; (when (re-search-forward "^\\*\\* .*:restart-here:" nil t) 314 | ;% ; (beginning-of-line) 315 | ;% ; (forward-line -1))) 316 | ;% ; (message "Headline not found"))) 317 | ;% 318 | ;% 319 | ;% 320 | ;% (defun my-delayed-org-setup () 321 | ;% "Run my-org-mode-setup and then my-open-log-file-and-move-above-tag." 322 | ;% (my-org-mode-setup) 323 | ;% (run-at-time "0.1 sec" nil 'my-open-log-file-and-move-above-tag)) 324 | ;% 325 | ;% (add-hook 'org-mode-hook 'my-delayed-org-setup) 326 | ;;; Open a file and move to a headline with a specific tag 327 | ;% The default tag is restart-here. 328 | ;% Example usage: 329 | ;% (open-org-file-and-move-to-tag "~/path/to/your/file.org" "your-tag") 330 | (defun open-org-file-and-move-to-tag (file &optional tag) 331 | "Open an Org file and move the cursor below a headline with a specific TAG. 332 | If TAG is not provided, use a hardcoded default tag. 333 | You have have to adjust the headline level in the funciton. 334 | The regular expression ^\\*\\* .*:%s: is used to search for second-level headlines (those starting with **) with the specified tag." 335 | (interactive "fOrg file: \nsTag (leave empty for default): ") 336 | (let ((tag (if (string= tag "") "restart-here" tag))) 337 | (find-file file) 338 | (goto-char (point-min)) 339 | (if (re-search-forward (format "^\\*\\* .*:%s:" tag) nil t) 340 | (org-end-of-subtree) 341 | (message "Tag not found")))) 342 | ;;; Play a YouTube video with mpv 343 | ;% You insert the YouTube url in the minibufffer. 344 | ;% You have to install mpv with a package manager and another binary package. 345 | ;% sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl 346 | ;% sudo chmod a+rx /usr/local/bin/youtube-dl 347 | 348 | ;;; open-template-with-citekey 349 | ;% Open template file renmaed with the citekey under the point. 350 | ;% This file is for use with an annotated bibliography. 351 | ;% Developed with the help of CoPilot. 352 | (defun open-new-abibnote-on-citekey () 353 | "Open a template file in Org-mode, rename it to the citekey under the cursor, 354 | and save it to '~/abibNotes/'. Citar has a function that will insert the citekey." 355 | (interactive) 356 | (let* ((citekey (thing-at-point 'word t)) 357 | (template-file "~/abibNotes/templates/abib-template.org") 358 | (output-dir "~/abibNotes/") 359 | (output-file (concat output-dir citekey ".org"))) 360 | (unless (file-exists-p output-dir) 361 | (make-directory output-dir t)) 362 | (if (and citekey (file-exists-p template-file)) 363 | (progn 364 | (copy-file template-file output-file t) 365 | (find-file output-file) 366 | (message "Template file saved as %s" output-file)) 367 | (message "Citekey or template file not found")))) 368 | (global-set-key (kbd "C-c z") 'open-new-abibnote-on-citekey) 369 | ;;;; play-youtube-video 370 | (defun play-youtube-video (url) 371 | "Play a YouTube video with mpv." 372 | (interactive "sYouTube URL: ") 373 | (start-process "mpv" nil "mpv" URL)) 374 | ;;; Protesilous Starvou functions 375 | ;;;; Functions to open popup menu when Emacs server is running 376 | ;% Source: https://www.youtube.com/watch?v=vbWxT8tht9A&list=PL8Bwba5vnQK14z96Gil86pLMDO2GnOhQ6 377 | ;% This function is used to capture notes when Emacs is not open. 378 | ;% This idea could be harness for other purposes. 379 | ;% You will need to map the 380 | (defun prot-window-delete-popup-frame (&rest _) 381 | "Kill selected selected frame if it has parameter `prot-window-popup-frame'. 382 | Use this function via a hook." 383 | (when (frame-parameter nil 'prot-window-popup-frame) 384 | (delete-frame))) 385 | (defmacro prot-window-define-with-popup-frame (command) 386 | "Define interactive function which calls COMMAND in a new frame. 387 | Make the new frame have the `prot-window-popup-frame' parameter." 388 | `(defun ,(intern (format "prot-window-popup-%s" command)) () 389 | ,(format "Run `%s' in a popup frame with `prot-window-popup-frame' parameter. 390 | Also see `prot-window-delete-popup-frame'." command) 391 | (interactive) 392 | (let ((frame (make-frame '((prot-window-popup-frame . t))))) 393 | (select-frame frame) 394 | (switch-to-buffer " prot-window-hidden-buffer-for-popup-frame") 395 | (condition-case nil 396 | (call-interactively ',command) 397 | ((quit error user-error) 398 | (delete-frame frame)))))) 399 | (declare-function org-capture "org-capture" (&optional goto keys)) 400 | (defvar org-capture-after-finalize-hook) 401 | (prot-window-define-with-popup-frame org-capture) 402 | (add-hook 'org-capture-after-finalize-hook #'prot-window-delete-popup-frame) 403 | 404 | ;%#+BEGIN_COMMENT 405 | ;% (declare-function tmr "tmr" (time &optional description acknowledgep)) 406 | ;% (defvar tmr-timer-created-functions) 407 | ;% (prot-window-define-with-popup-frame tmr) 408 | ;% 409 | ;% (add-hook 'tmr-timer-created-functions #'prot-window-delete-popup-frame) 410 | ;%#+END_COMMENT 411 | 412 | ;;;;; The emacsclient calls that need ot be bound to system-wide keys 413 | ;% The emacsclient is an Emac version agnostic. 414 | ;% 415 | ;% alias oc="emacslient -e '(prot-window-popup-org-capture)'" 416 | ;% emacsclient -e '(prot-window-popup-tmr)' 417 | ;;; Reload the initialization file after editing it in Emacs 418 | (defun reload-init-e29f () 419 | "Reload the init.el file for e29org. Edit the path to suite your needs." 420 | (interactive) 421 | (load-file "~/e29fewpackages/init.el")) 422 | ;;; Spawn a new shell with the supplied title 423 | (defun spawn-shell (name) 424 | "Invoke shell test" 425 | (interactive "MName of shell buffer to create: ") 426 | (pop-to-buffer (get-buffer-create (generate-new-buffer-name name))) 427 | (shell (current-buffer)) 428 | (process-send-string nil "echo 'test1'\n") 429 | (process-send-string nil "echo 'test2'\n")) 430 | ;;; Split line with many sentences into one line per sentence. 431 | (defun split-sentences-into-lines (start end) 432 | "Move each sentence in the region to its own line." 433 | (interactive "r") 434 | (save-excursion 435 | (goto-char start) 436 | (while (re-search-forward "\\([.!?]\\)\\s-+" end t) 437 | (replace-match "\\1\n")))) 438 | ;% Bind the function to a key combination, e.g., C-c s 439 | (global-set-key (kbd "C-c s") 'split-sentences-into-lines) 440 | ;;; Move the cursor to the minibuffer without using the mouse 441 | ;% From video https://www.youtube.com/watch?v=X8c_TrGfYcM&t=15s using Emacs as a multiplexer." 442 | ;% Derived from http://stackoverflow.com/a/4116113/446256. 443 | (defun switch-to-minibuffer () 444 | "Switch to minibuffer window." 445 | (interactive) 446 | (if (active-minibuffer-window) 447 | (select-window (active-minibuffer-window)) 448 | (error "Minibuffer is not active"))) 449 | (global-set-key "\C-cm" 'switch-to-minibuffer) ;; Bind to `C-c m' for minibuffer. 450 | (message "End of user-defined functions.") 451 | ;; Package configuration section 452 | (message "Start package configurations in alphabetical order by package name.") 453 | (message "Start A package configurations") 454 | ;;; A 455 | ;;;; AUCTeX 456 | ;% This is the more advanced LaTeX. 457 | ;% Emacs has native LaTeX support that AUCTeX is an alternative to. 458 | (setq exec-path (append '("/usr/local/texlive/2024/bin/universal-darwin") exec-path)) 459 | (setenv "PATH" (concat "/usr/local/texlive/2024/bin/universal-darwin:" (getenv "PATH"))) 460 | (use-package auctex 461 | :straight t 462 | :defer t) 463 | (message "Start C package configurations") 464 | ;;; C 465 | ;;;; Citar 466 | ;% Citar is a bibliographic management system that is an alternative to org-ref. 467 | ;% Citar can operate in tex and org file whereas org-ref is limited to org-mode files. 468 | (use-package citar 469 | :straight t 470 | :bind (("C-c b" . citar-insert-citation) 471 | :map minibuffer-local-map 472 | ("M-b" . citar-insert-preset)) 473 | :custom 474 | (citar-bibliography '("/Users/blaine/Documents/global.bib")) 475 | (citar-library-paths '("/Users/blaine/0papersLabeled") '("/Users/blaine/0booksUnlabeled")) 476 | (citar-library-file-extensions '("pdf" "epub")) 477 | :hook 478 | ;; enable autocompletion in buffer of citekeys 479 | (LaTeX-mode . citar-capf-setup) 480 | (org-mode . citar-capf-setup)) 481 | ;;;; citar-org-roam 482 | ;% Use to generate literature notes for bib entries accessed with citar. 483 | (use-package citar-org-roam 484 | :straight t 485 | :after (citar org-roam) 486 | :config (citar-org-roam-mode)) 487 | (setq citar-org-roam-note-title-template "${author} - ${title}") 488 | (setq org-roam-capture-templates 489 | '(("d" "default" plain 490 | "%?" 491 | :target 492 | (file+head 493 | "%<%Y%m%d%H%M%S>-${slug}.org" 494 | "#+title: ${note-title}\n") 495 | :unnarrowed t) 496 | ("n" "literature note" plain 497 | "%?" 498 | :target 499 | (file+head 500 | "%(expand-file-name (or citar-org-roam-subdir \"\") org-roam-directory)/${citar-citekey}.org" 501 | "#+title: ${citar-citekey} (${citar-date}). ${note-title}.\n#+created: %U\n#+last_modified: %U\n\n") 502 | :unnarrowed t))) 503 | (setq citar-org-roam-capture-template-key "n") 504 | 505 | ; (citar-register-notes-source 506 | ; 'orb-citar-source (list :name "Org-Roam Notes" 507 | ; :category 'org-roam-node 508 | ; :items #'citar-org-roam--get-candidates 509 | ; :hasitems #'citar-org-roam-has-notes 510 | ; :open #'citar-org-roam-open-note 511 | ; :create #'orb-citar-edit-note 512 | ; :annotate #'citar-org-roam--annotate)) 513 | 514 | (setq citar-notes-source 'orb-citar-source) 515 | 516 | 517 | (defvar bibliographic-entry-template 518 | "#+title: %s 519 | #+subtitle: Bibliographic Notes 520 | #+author: %s 521 | #+email: %s 522 | #+property: header-args+ :comments link 523 | #+cite_export: csl apa.csl 524 | 525 | * Notes 526 | 527 | | 528 | 529 | * References 530 | 531 | #+begin_src bibtex :tangle %s :exports none 532 | %s 533 | #+end_src 534 | 535 | #+print_bibliography:") 536 | 537 | (defun my-citar-org-open-notes (key entry) 538 | (let* ((bib (concat my/bibtex-directory key ".bib")) 539 | (org (concat my/bibtex-directory key ".org")) 540 | (new (not (file-exists-p org)))) 541 | (funcall citar-file-open-function org) 542 | (when (and new (eq (buffer-size) 0)) 543 | (insert (format bibliographic-entry-template 544 | (assoc-default "title" entry) 545 | user-full-name 546 | user-mail-address 547 | bib 548 | (with-temp-buffer 549 | (insert-file-contents bib) 550 | (buffer-string)))) 551 | (search-backward "|") 552 | (delete-char 1)))) 553 | 554 | 555 | ; Define the Template: 556 | ; 557 | ; The bibliographic-entry-template variable holds the template string for the bibliographic entry. 558 | ; Function to Open Notes: 559 | ; 560 | ; The my-citar-org-open-notes function constructs the paths for the .bib and .org files, opens the .org file, and inserts the formatted template if the file is new. 561 | ; Set the Default Note Function: 562 | ; 563 | ; The setq-default line sets my-citar-org-open-notes as the default function for opening notes with citar. 564 | ; Usage: 565 | ; Add the above code to your init.el file. 566 | ; Ensure that my/bibtex-directory is defined and points to the directory where your BibTeX files are stored. 567 | ; When you open a note with citar, it will use the specified template and function 568 | (setq-default citar-open-note-function 'my-citar-org-open-notes) 569 | 570 | 571 | (use-package codeium 572 | :straight '(:type git :host github :repo "Exafunction/codeium.el") 573 | :init 574 | ;; use globally 575 | (add-to-list 'completion-at-point-functions #'codeium-completion-at-point) 576 | ;; or on a hook 577 | ;; (add-hook 'python-mode-hook 578 | ;; (lambda () 579 | ;; (setq-local completion-at-point-functions '(codeium-completion-at-point)))) 580 | 581 | ;; if you want multiple completion backends, use cape (https://github.com/minad/cape): 582 | ;; (add-hook 'python-mode-hook 583 | ;; (lambda () 584 | ;; (setq-local completion-at-point-functions 585 | ;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point))))) 586 | ;; an async company-backend is coming soon! 587 | 588 | ;; codeium-completion-at-point is autoloaded, but you can 589 | ;; optionally set a timer, which might speed up things as the 590 | ;; codeium local language server takes ~0.2s to start up 591 | ;; (add-hook 'emacs-startup-hook 592 | ;; (lambda () (run-with-timer 0.1 nil #'codeium-init))) 593 | 594 | ;; :defer t ;; lazy loading, if you want 595 | 596 | :config 597 | (setq use-dialog-box nil) ;; do not use popup boxes 598 | 599 | ;; if you don't want to use customize to save the api-key 600 | ;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") 601 | 602 | ;; get codeium status in the modeline 603 | (setq codeium-mode-line-enable 604 | (lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion))))) 605 | (add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t) 606 | ;; alternatively for a more extensive mode-line 607 | ;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t) 608 | 609 | ;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server 610 | (setq codeium-api-enabled 611 | (lambda (api) 612 | (memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion)))) 613 | ;; you can also set a config for a single buffer like this: 614 | ;; (add-hook 'python-mode-hook 615 | ;; (lambda () 616 | ;; (setq-local codeium/editor_options/tab_size 4))) 617 | 618 | ;; You can overwrite all the codeium configs! 619 | ;; for example, we recommend limiting the string sent to codeium for better performance 620 | (defun my-codeium/document/text () 621 | (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max)))) 622 | ;; if you change the text, you should also change the cursor_offset 623 | ;; warning: this is measured by UTF-8 encoded bytes 624 | (defun my-codeium/document/cursor_offset () 625 | (codeium-utf8-byte-length 626 | (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point)))) 627 | (setq codeium/document/text 'my-codeium/document/text) 628 | (setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset) 629 | ) 630 | 631 | 632 | 633 | 634 | ;;;; company-box 635 | ;;;;; formats the options delivered by the company autocompletion system 636 | (use-package company-box 637 | :straight t 638 | :config 639 | (setq company-box-max-candidates 50 640 | company-frontends '(company-tng-frontend company-box-frontend) 641 | company-box-icons-alist 'company-box-icons-all-the-icons)) 642 | (with-eval-after-load 'company 643 | (define-key company-active-map 644 | (kbd "TAB") 645 | #'company-complete-common-or-cycle) 646 | (define-key company-active-map 647 | (kbd "") 648 | (lambda () 649 | (interactive) 650 | (company-complete-common-or-cycle -1)))) 651 | (with-eval-after-load 'company 652 | (define-key company-active-map (kbd "M-.") #'company-show-location) 653 | (define-key company-active-map (kbd "RET") nil)) 654 | ;;;; Company Configuration 655 | ;% This is a popular autocompletion package. 656 | ;% Source: https://github.com/Exafunction/codeium.el 657 | (use-package company 658 | :straight t 659 | :defer 0.1 660 | :hook ((emacs-lisp-mode . (lambda () 661 | (setq-local company-backends '(company-elisp)))) 662 | (emacs-lisp-mode . company-mode)) 663 | :config 664 | (global-company-mode t) 665 | (company-tng-configure-default) ; restore old tab behavior 666 | (setq-default 667 | company-idle-delay 0.05 668 | company-require-match nil 669 | company-minimum-prefix-length 1 670 | ;; get only preview 671 | ;; company-frontends '(company-preview-frontend) 672 | ;; also get a drop down 673 | company-frontends '(company-pseudo-tooltip-frontend company-preview-frontend) 674 | )) 675 | 676 | 677 | ;; ;;;; codeium 678 | ;; ;% Source: https://github.com/Exafunction/codeium.el 679 | ;; (straight-use-package '(codeium :type git :host github :repo "Exafunction/codeium.el") 680 | ;; :init 681 | ;; ;; use globally 682 | ;; (add-to-list 'completion-at-point-functions #'codeium-completion-at-point) 683 | ;; ;; or on a hook 684 | ;; ;; (add-hook 'python-mode-hook 685 | ;; ;; (lambda () 686 | ;; ;; (setq-local completion-at-point-functions '(codeium-completion-at-point)))) 687 | 688 | ;; ;; if you want multiple completion backends, use cape (https://github.com/minad/cape): 689 | ;; ;; (add-hook 'python-mode-hook 690 | ;; ;; (lambda () 691 | ;; ;; (setq-local completion-at-point-functions 692 | ;; ;; (list (cape-capf-super #'codeium-completion-at-point #'lsp-completion-at-point))))) 693 | ;; ;; an async company-backend is coming soon! 694 | 695 | ;; ;; codeium-completion-at-point is autoloaded, but you can 696 | ;; ;; optionally set a timer, which might speed up things as the 697 | ;; ;; codeium local language server takes ~0.2s to start up 698 | ;; ;; (add-hook 'emacs-startup-hook 699 | ;; ;; (lambda () (run-with-timer 0.1 nil #'codeium-init))) 700 | 701 | ;; ;; :defer t ;; lazy loading, if you want 702 | ;; :config 703 | ;; (setq use-dialog-box nil) ;; do not use popup boxes 704 | 705 | ;; ;; if you don't want to use customize to save the api-key 706 | ;; ;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") 707 | 708 | ;; ;; get codeium status in the modeline 709 | ;; (setq codeium-mode-line-enable 710 | ;; (lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion))))) 711 | ;; (add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t) 712 | ;; ;; alternatively for a more extensive mode-line 713 | ;; ;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t) 714 | 715 | ;; ;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server 716 | ;; (setq codeium-api-enabled 717 | ;; (lambda (api) 718 | ;; (memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion)))) 719 | ;; ;; you can also set a config for a single buffer like this: 720 | ;; ;; (add-hook 'python-mode-hook 721 | ;; ;; (lambda () 722 | ;; ;; (setq-local codeium/editor_options/tab_size 4))) 723 | 724 | ;; ;; You can overwrite all the codeium configs! 725 | ;; ;; for example, we recommend limiting the string sent to codeium for better performance 726 | ;; (defun my-codeium/document/text () 727 | ;; (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max)))) 728 | ;; ;; if you change the text, you should also change the cursor_offset 729 | ;; ;; warning: this is measured by UTF-8 encoded bytes 730 | ;; (defun my-codeium/document/cursor_offset () 731 | ;; (codeium-utf8-byte-length 732 | ;; (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point)))) 733 | ;; (setq codeium/document/text 'my-codeium/document/text) 734 | ;; (setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset)) 735 | 736 | 737 | 738 | ;;;; copilot 739 | ;% see https://github.com/copilot-emacs/copilot.el?tab=readme-ov-file for install protocol. 740 | ;% Requires a Github Copilot subscription. 741 | ;% I had to configure the copilot-node-executable variable to point to the correct executable. 742 | ;% Configure by entering 743 | ;% See for fancy functions to enhance experience: 744 | (use-package copilot 745 | :straight (:host github :repo "copilot-emacs/copilot.el" :files ("*.el")) 746 | :ensure t) 747 | (add-hook 'prog-mode-hook 'copilot-mode) 748 | (define-key copilot-completion-map (kbd "") 'copilot-accept-completion) 749 | (define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion) 750 | (message "Finished C package configurations") 751 | 752 | ;;; E 753 | (message "Started E packages configurations") 754 | ;;;; emacsql 755 | (use-package emacsql 756 | :straight t) 757 | ; (package-use emacsql-sqlite 758 | ; :straight t) 759 | (message "Finished E packages configurations") 760 | ;;;; exec-path-from-shell 761 | (use-package exec-path-from-shell 762 | :straight t 763 | :config 764 | (setq exec-path-from-shell-arguments nil) 765 | (setq exec-path-from-shell-variables '("PATH" "MANPATH" "SHELL")) 766 | (exec-path-from-shell-initialize)) 767 | ; ;;; Shell configuration 768 | ; ;% Let Emacs know which shell that you are using. 769 | ; (use-package exec-path-from-shell 770 | ; :straight t 771 | ; :init 772 | ; (setenv "SHELL" "/opt/homebrew/bin/zsh") 773 | ; :if (memq window-system '(mac ns x)) 774 | ; :config 775 | ; (setq exec-path-from-shell-variables '("PATH" "GOPATH" "PYTHONPATH")) 776 | ; (exec-path-from-shell-initialize)) 777 | 778 | 779 | ;;; F 780 | (message "Started F packages configurations") 781 | ;;;; frame-tabs 782 | ;% This package is fanstastic! I love the tiny tabs. 783 | ;% They ease navigating between buffers, especially when using emacsclient. 784 | (frame-tabs-mode) 785 | (message "Finished F packages configurations") 786 | 787 | 788 | 789 | (message "Started J packages configurations") 790 | ;;;; Jinx 791 | ;% The enhancted spell checker. 792 | ;% Uses fewer resources than flyspell and is faster. 793 | ;% https://github.com/minad/jinx/wiki 794 | ; (use-package jinx 795 | ; :straight (jinx :type git :host github :repo "minad/jinx") 796 | ; :hook (emacs-startup . global-jinx-mode) 797 | ; :bind (("M-$" . jinx-correct) 798 | ; ("C-M-$" . jinx-languages))) 799 | ; 800 | ; ;% Enable Jinx globally 801 | ; (add-hook 'emacs-startup-hook #'global-jinx-mode) 802 | ; 803 | ; (keymap-global-set "M-$" #'jinx-correct) 804 | ; (keymap-global-set "C-M-$" #'jinx-languages) 805 | (message "Finished J packages configurations") 806 | (message "Started L packages configurations") 807 | ;;; L 808 | ;;;; listen 809 | ;% MP3 player 810 | ;% No configuration required. 811 | ;% package-install listen 812 | ;% Requires vlc installed via home brew. 813 | ;% Configure via customize the file path to your mp3 files. 814 | ;% Adding mp3 files without metadata to queues is tricky. 815 | ;% Free mp3's of classical music can be found here: https://archive.org/ and here 816 | ;;;; lsp-mode 817 | ; ;% This mode is required to be able to use other lsp modes. 818 | ; (use-package lsp-mode 819 | ; :straight t 820 | ; :commands (lsp lsp-deferred) 821 | ; :bind (:map lsp-mode-map 822 | ; ("C-c d" . lsp-describe-thing-at-point) 823 | ; ("C-c a" . lsp-execute-code-action)) 824 | ; :bind-keymap ("C-c l" . lsp-command-map) 825 | ; :hook ((latex-mode . lsp-deferred) 826 | ; (lsp-mode . lsp-enable-which-key-integration)) 827 | ; :config 828 | ; (lsp-enable-which-key-integration t) 829 | ; (setq lsp-headerline-breadcrumb-enable nil)) 830 | ; 831 | ; ; LSP-MODE CONFIGURATION 832 | ; ;; 833 | ; ;; add to init.el 834 | ; ;; 835 | ; ;; `lsp-mode` excels over eglot in that you can run it in parallel alongside 836 | ; ;; other LSPs. 837 | ;;;; lsp-mode 838 | ;% Config for openai 839 | ; (use-package lsp-mode 840 | ; :straight t 841 | ; :commands lsp 842 | ; :hook 843 | ; ((LaTeX-mode 844 | ; TeX-mode 845 | ; bibtex-mode 846 | ; c++-mode 847 | ; c-mode 848 | ; clojure-mode 849 | ; coffee-mode 850 | ; csharp-mode 851 | ; css-mode 852 | ; diff-mode 853 | ; dockerfile-mode 854 | ; ess-mode 855 | ; emacs-lisp-mode 856 | ; fsharp-mode 857 | ; go-mode 858 | ; groovy-mode 859 | ; html-mode 860 | ; java-mode 861 | ; js-mode 862 | ; js2-mode 863 | ; json-mode 864 | ; less-css-mode 865 | ; lua-mode 866 | ; makefile-mode 867 | ; markdown-mode 868 | ; nxml-mode 869 | ; objc-mode 870 | ; org-mode 871 | ; perl-mode 872 | ; php-mode 873 | ; powershell-mode 874 | ; python-mode 875 | ; ruby-mode 876 | ; rust-mode 877 | ; sass-mode 878 | ; scss-mode 879 | ; sh-mode 880 | ; sql-mode 881 | ; swift-mode 882 | ; text-mode 883 | ; toml-mode 884 | ; typescript-mode 885 | ; web-mode 886 | ; yaml-mode 887 | ; ) . (lambda () 888 | ; (uniteai-mode 1) 889 | ; (lsp))) 890 | ; 891 | ; :init 892 | ; ;; Tell lsp-mode not to ask if you're ok with the server modifying the document. 893 | ; (setq lsp-restart 'auto-restart) 894 | ; 895 | ; :config 896 | ; ;; if it can't launch the right LSP, don't pester 897 | ; (setq lsp-enable-suggest-server-download nil) 898 | ; 899 | ; :bind 900 | ; ;; Code Actions 901 | ; ("M-'" . lsp-execute-code-action)) 902 | ; 903 | ; 904 | ; ;;;;;;;;;; 905 | ; 906 | ; ;; Global stopping 907 | ; (defun lsp-stop () 908 | ; (interactive) 909 | ; (let* ((doc (lsp--text-document-identifier))) 910 | ; (lsp-request "workspace/executeCommand" 911 | ; `(:command "command.stop" 912 | ; :arguments ,(vector doc))))) 913 | ; 914 | ; ;; Example Counter 915 | ; (defun lsp-example-counter () 916 | ; (interactive) 917 | ; (let* ((doc (lsp--text-document-identifier)) 918 | ; (pos (lsp--cur-position))) 919 | ; (lsp-request "workspace/executeCommand" 920 | ; `(:command "command.exampleCounter" 921 | ; :arguments ,(vector doc pos))))) 922 | ; 923 | ; ;; Document 924 | ; (defun lsp-document () 925 | ; (interactive) 926 | ; (unless (region-active-p) 927 | ; (error "No region selected")) 928 | ; (let* ( 929 | ; (doc (lsp--text-document-identifier)) 930 | ; (range (list :start (lsp--point-to-position (region-beginning)) 931 | ; :end (lsp--point-to-position (region-end))))) 932 | ; (lsp-request "workspace/executeCommand" 933 | ; `(:command "command.document" 934 | ; :arguments ,(vector doc range))))) 935 | ; 936 | ; ;; Local LLM 937 | ; (defun lsp-local-llm () 938 | ; (interactive) 939 | ; (unless (region-active-p) 940 | ; (error "No region selected")) 941 | ; (let* ((doc (lsp--text-document-identifier)) 942 | ; (range (list :start (lsp--point-to-position (region-beginning)) 943 | ; :end (lsp--point-to-position (region-end))))) 944 | ; (lsp-request "workspace/executeCommand" 945 | ; `(:command "command.localLlmStream" 946 | ; :arguments ,(vector doc range))))) 947 | ; 948 | ; ;; Transcription 949 | ; (defun lsp-transcribe () 950 | ; (interactive) 951 | ; (let* ((doc (lsp--text-document-identifier)) 952 | ; (pos (lsp--cur-position))) 953 | ; (lsp-request "workspace/executeCommand" 954 | ; `(:command "command.transcribe" 955 | ; :arguments ,(vector doc pos))))) 956 | ; 957 | ; ;; OpenAI 958 | ; (defun lsp-openai-gpt () 959 | ; (interactive) 960 | ; (unless (region-active-p) 961 | ; (error "No region selected")) 962 | ; (let* ( 963 | ; (doc (lsp--text-document-identifier)) 964 | ; (range (list :start (lsp--point-to-position (region-beginning)) 965 | ; :end (lsp--point-to-position (region-end))))) 966 | ; (lsp-request "workspace/executeCommand" 967 | ; `(:command "command.openaiAutocompleteStream" 968 | ; :arguments ,(vector doc range "FROM_CONFIG_COMPLETION" "FROM_CONFIG"))))) 969 | ; 970 | ; (defun lsp-openai-chatgpt () 971 | ; (interactive) 972 | ; (unless (region-active-p) 973 | ; (error "No region selected")) 974 | ; (let* ( 975 | ; (doc (lsp--text-document-identifier)) 976 | ; (range (list :start (lsp--point-to-position (region-beginning)) 977 | ; :end (lsp--point-to-position (region-end))))) 978 | ; (lsp-request "workspace/executeCommand" 979 | ; `(:command "command.openaiAutocompleteStream" 980 | ; :arguments ,(vector doc range "FROM_CONFIG_CHAT" "FROM_CONFIG"))))) 981 | ; 982 | ; 983 | ; ;; Local LLM 984 | ; (defun lsp-text-to-speech-save () 985 | ; (interactive) 986 | ; (unless (region-active-p) 987 | ; (error "No region selected")) 988 | ; (let* ((doc (lsp--text-document-identifier)) 989 | ; (range (list :start (lsp--point-to-position (region-beginning)) 990 | ; :end (lsp--point-to-position (region-end))))) 991 | ; (lsp-request "workspace/executeCommand" 992 | ; `(:command "command.textToSpeechSave" 993 | ; :arguments ,(vector doc range))))) 994 | ; 995 | ; ;; Local LLM 996 | ; (defun lsp-text-to-speech-play () 997 | ; (interactive) 998 | ; (unless (region-active-p) 999 | ; (error "No region selected")) 1000 | ; (let* ((doc (lsp--text-document-identifier)) 1001 | ; (range (list :start (lsp--point-to-position (region-beginning)) 1002 | ; :end (lsp--point-to-position (region-end))))) 1003 | ; (lsp-request "workspace/executeCommand" 1004 | ; `(:command "command.textToSpeechPlay" 1005 | ; :arguments ,(vector doc range))))) 1006 | ; 1007 | ; 1008 | ; (define-minor-mode uniteai-mode 1009 | ; "Minor mode for interacting with UniteAI server." 1010 | ; :lighter " UniteAI" 1011 | ; :keymap (let ((map (make-sparse-keymap))) 1012 | ; (define-key map (kbd "C-c l s") 'lsp-stop) 1013 | ; (define-key map (kbd "C-c l e") 'lsp-example-counter) 1014 | ; (define-key map (kbd "C-c l l") 'lsp-local-llm) 1015 | ; (define-key map (kbd "C-c l v") 'lsp-transcribe) 1016 | ; (define-key map (kbd "C-c l g") 'lsp-openai-gpt) 1017 | ; (define-key map (kbd "C-c l c") 'lsp-openai-chatgpt) 1018 | ; (define-key map (kbd "C-c l d") 'lsp-document) 1019 | ; 1020 | ; (define-key map (kbd "C-c l a s") 'lsp-text-to-speech-save) 1021 | ; (define-key map (kbd "C-c l a p") 'lsp-text-to-speech-play) 1022 | ; map)) 1023 | ; 1024 | ; (lsp-register-client 1025 | ; (make-lsp-client 1026 | ; 1027 | ; ;; STDIO Mode 1028 | ; :new-connection (lsp-stdio-connection `("uniteai_lsp" "--stdio")) 1029 | ; 1030 | ; ;; ;; TCP Mode 1031 | ; ;; :new-connection (lsp-tcp-connection 1032 | ; ;; (lambda (port) 1033 | ; ;; `("uniteai_lsp" "--tcp" "--lsp_port" ,(number-to-string port)))) 1034 | ; 1035 | ; :priority -3 1036 | ; :major-modes '(python-mode markdown-mode org-mode) 1037 | ; :server-id 'uniteai 1038 | ; :add-on? t ; run in parallel to other LSPs 1039 | ; )) 1040 | ; 1041 | ; (setq lsp-tcp-connection-timeout 5.0) ; default was 2.0 1042 | 1043 | ;;;; lsp-latex 1044 | (use-package lsp-latex 1045 | :straight t 1046 | :after lsp-mode 1047 | :hook (latex-mode . lsp-latex-enable)) 1048 | ;;;; lsp-ltex (the languagetool lsp server) 1049 | (use-package lsp-ltex 1050 | :straight t 1051 | :after lsp-mode 1052 | :hook ((text-mode . lsp) 1053 | (latex-mode . lsp) 1054 | (org-mode . lsp)) 1055 | :config 1056 | (setq lsp-ltex-language "en-US") 1057 | :init 1058 | (setq lsp-ltex-version "16.0.0")) 1059 | ;;;; lsp-ui 1060 | (use-package lsp-ui 1061 | :straight t 1062 | :commands lsp-ui-mode) 1063 | ;;;; lsp-treemacs 1064 | (use-package lsp-treemacs 1065 | :straight t 1066 | :commands lsp-treemacs-errors-list) 1067 | (message "Finished L package configurations") 1068 | (message "Start M package configurations") 1069 | ;;; M 1070 | ;;;; Marginalia Configuration 1071 | ;% This package adds the first line of the docstring for the commands returned by vertico. 1072 | (use-package marginalia 1073 | :straight (marginalia :type git :host github :repo "minad/marginalia") 1074 | :config 1075 | (marginalia-mode)) 1076 | (customize-set-variable 'marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) 1077 | (marginalia-mode 1) 1078 | ;;;; Markdown 1079 | ;% Sometimes we have to edit the README.md files for our secret manuscirpt repositroies on GitHub or Codeberg. 1080 | (use-package markdown-mode 1081 | :ensure t 1082 | :mode ("\\.md\\'" . markdown-mode) 1083 | :init (setq markdown-command "multimarkdown")) 1084 | (with-eval-after-load 'markdown-mode 1085 | (define-key markdown-mode-map (kbd "M-") 'markdown-move-item-up) 1086 | (define-key markdown-mode-map (kbd "M-") 'markdown-move-item-down)) 1087 | ;% Functions to move list items up and down 1088 | (defun markdown-move-item-up () 1089 | "Move the current markdown list item up." 1090 | (interactive) 1091 | (let ((col (current-column))) 1092 | (markdown-beginning-of-item) 1093 | (transpose-lines 1) 1094 | (forward-line -2) 1095 | (forward-char col))) 1096 | (defun markdown-move-item-down () 1097 | "Move the current markdown list item down." 1098 | (interactive) 1099 | (let ((col (current-column))) 1100 | (markdown-beginning-of-item) 1101 | (forward-line 1) 1102 | (transpose-lines 1) 1103 | (forward-line -1) 1104 | (forward-char col))) 1105 | ;;;; Math-preview that is mode agnostic 1106 | ;% Uses MathJaX. 1107 | ;% You have to download and install the binary 1108 | ; (use-package math-preview 1109 | ; :straight t 1110 | ; :custom (math-preview-command "/Users/blaine/.nvm/versions/node/v22.4.0/lib/node_modules/math-preview/math-preview.js")) 1111 | 1112 | 1113 | ;% ;;;; Mingus 1114 | ;% ;% For Linux users. 1115 | ;% ;% A MPD client for Emacs that provides a user-friendly interface for managing your music library and playlists. 1116 | ;% (use-package mingus 1117 | ;% :straight t 1118 | ;% :config 1119 | ;% (setq mingus-mpd-host "localhost" 1120 | ;% mingus-mpd-port "6600")) 1121 | ;% ;% Mingus can exceed the buffer limits. 1122 | ;% ;% Keep playists short. 1123 | ;% (setq max-specpdl-size 13000) ;; Default is 1300 1124 | ;% (setq max-lisp-eval-depth 8000) ;; Default is 800 1125 | ;% ;;;; MPC 1126 | ;% ;% A lighter MPD client 1127 | ;% ;% Must install mpc outside of Emacs. I used home brew. 1128 | ;% ;% Check connection to MPD with `mpc -h localhost -p 6600 status` 1129 | ;% (use-package mpc 1130 | ;% :straight t 1131 | ;% :config 1132 | ;% (setq mpc-host "localhost" 1133 | ;% mpc-port "6600")) 1134 | ;% (setenv "MPD_HOST" "localhost") 1135 | ;% (setenv "MPD_PORT" "6600") 1136 | ;% ;;;; MPD 1137 | ;% ;% Runs as a daemon. 1138 | ;% ;% Can install with home brew on the Mac. 1139 | ;% (use-package mpdel 1140 | ;% :straight (mpdel :type git :host github :repo "mpdel/mpdel") 1141 | ;% :config 1142 | ;% (setq mpdel-prefix-key (kbd "C-c m")) 1143 | ;% (mpdel-mode)) 1144 | (message "Finished M packages configurations") 1145 | (message "Start O package configurations") 1146 | ;;; O 1147 | ;;;; orderless 1148 | ;% This package returns search terms without regard to their order in the name of the returned function or command. 1149 | (use-package orderless 1150 | :straight t 1151 | :init 1152 | (setq completion-styles '(orderless) 1153 | completion-category-defaults nil 1154 | completion-category-overrides '((file (styles partial-completion))))) 1155 | ;;;; LaTeX config for org-mode 1156 | (with-eval-after-load 'ox-latex 1157 | (setq org-latex-pdf-process 1158 | '("pdflatex -interaction nonstopmode --shell-escape -synctex=1 -output-directory %o %f" 1159 | "bibtex %b" 1160 | "pdflatex -interaction nonstopmode --shell-escape -synctex=1 -output-directory %o %f" 1161 | "pdflatex -interaction nonstopmode --shell-escape -synctex=1 -output-directory %o %f"))) 1162 | 1163 | 1164 | ;;;; Org-agenda 1165 | ;% This can be complex to configure. 1166 | 1167 | (setq org-agenda-start-with-log-mode t) 1168 | (setq org-log-done 'time) 1169 | (setq org-log-into-drawer t) 1170 | 1171 | ;;;;; Follow links 1172 | (setq org-return-follows-link t) 1173 | 1174 | ;;;;; Treat *.org files as org-mode files 1175 | (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) 1176 | 1177 | ;;;;; Hide the emphasis markers so you just see bold text as BOLD-TEXT and not *BOLD-TEXT* 1178 | (setq org-hide-emphasis-markers t) 1179 | 1180 | ;;;;; Stoup's fonts for org 1181 | ;% These settings have been added to the customization section. 1182 | ;% They can only be called once in an init.el file. 1183 | ;% #+BEGIN-COMMENT 1184 | ; (let* ((variable-tuple 1185 | ; (cond ((x-list-fonts "ETBembo") '(:font "ETBembo")) 1186 | ; ((x-list-fonts "Source Sans Pro") '(:font "Source Sans Pro")) 1187 | ; ((x-list-fonts "Lucida Grande") '(:font "Lucida Grande")) 1188 | ; ((x-list-fonts "Verdana") '(:font "Verdana")) 1189 | ; ((x-family-fonts "Sans Serif") '(:family "Sans Serif")) 1190 | ; (nil (warn "Cannot find a Sans Serif Font. Install Source Sans Pro.")))) 1191 | ; (base-font-color (face-foreground 'default nil 'default)) 1192 | ; (headline `(:inherit default :weight bold :foreground ,base-font-color))) 1193 | ; 1194 | ; (custom-theme-set-faces 1195 | ; 'user 1196 | ; `(org-level-8 ((t (,@headline ,@variable-tuple)))) 1197 | ; `(org-level-7 ((t (,@headline ,@variable-tuple)))) 1198 | ; `(org-level-6 ((t (,@headline ,@variable-tuple)))) 1199 | ; `(org-level-5 ((t (,@headline ,@variable-tuple)))) 1200 | ; `(org-level-4 ((t (,@headline ,@variable-tuple :height 1.1)))) 1201 | ; `(org-level-3 ((t (,@headline ,@variable-tuple :height 1.2)))) 1202 | ; `(org-level-2 ((t (,@headline ,@variable-tuple :height 1.3)))) 1203 | ; `(org-level-1 ((t (,@headline ,@variable-tuple :height 1.5)))) 1204 | ; `(org-document-title ((t (,@headline ,@variable-tuple :height 1.6 :underline nil)))))) 1205 | ;% #+END_COMMENT 1206 | 1207 | ;;;;; Org-agenda key-bindings 1208 | (define-key global-map "\C-ca" 'org-agenda) 1209 | (setq org-log-done t) 1210 | (define-key global-map "\C-cc" 'org-capture) 1211 | (define-key global-map "\C-cl" 'org-store-link) 1212 | (global-set-key (kbd "C-c v") 'org-refile) 1213 | ;% Note that I have more capture commands below. 1214 | (setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA") 1215 | ;;;;; Source of TODO keywords read into org-agenda 1216 | (setq org-agenda-files '("/Users/blaine/.notes" 1217 | "/Users/blaine/gtd/tasks/JournalArticles.org" 1218 | "/Users/blaine/0573CrystalDetectionMeasurement/log0573.org" 1219 | "/Users/blaine/0598tenRulesWritingLog/cb/log0598tsrWritingLog.org" 1220 | "/Users/blaine/gtd/tasks/Proposals.org" 1221 | "/Users/blaine/1019NIHemofat/cb/log1019.org" 1222 | "/Users/blaine/gtd/tasks/Books.org" 1223 | "/Users/blaine/gtd/tasks/Talks.org" 1224 | "/Users/blaine/gtd/tasks/Posters.org" 1225 | "/Users/blaine/gtd/tasks/ManuscriptReviews.org" 1226 | "/Users/blaine/gtd/tasks/Private.org" 1227 | "/Users/blaine/gtd/tasks/Service.org" 1228 | "/Users/blaine/gtd/tasks/Teaching.org" 1229 | "/Users/blaine/gtd/tasks/Workshops.org" 1230 | "/Users/blaine/gtd/tasks/springsem24.org" 1231 | "/Users/blaine/gtd/tasks/summersem24.org" 1232 | "/Users/blaine/gtd/tasks/fallsem24.org")) 1233 | ;;;;; Order of TODO keywords 1234 | ;% Cycle through these keywords with shift right or left arrows. 1235 | (setq org-todo-keywords 1236 | '((sequence "TODO(t)" "PLANNING(p)" "IN-PROGRESS(i@/!)" "WAITING(w!)" "CAL(a)" "PROJ(j)" "|" "DONE(d!)" "SOMEDAY(s!)" "CANCELLED(c!)" ))) 1237 | ;;;;; TODO keyword colors 1238 | (setq org-todo-keyword-faces 1239 | '( 1240 | ("TODO" . (:foreground "Red" :weight bold)) 1241 | ("PLANNING" . (:foreground "DeepPink" :weight bold)) 1242 | ("IN-PROGRESS" . (:foreground "Cyan" :weight bold)) 1243 | ("WAITING" . (:foreground "DarkOrange" :weight bold)) 1244 | ("CAL" . (:foreground "GoldenOrange" :weight bold)) 1245 | ("PROJ" . (:foreground "LimeGreen" :weight bold)) 1246 | ("DONE" . (:foreground "LimeGreen" :weight bold)) 1247 | ("SOMEDAY" . (:foreground "LimeGreen" :weight bold)) 1248 | ("CANCELLED" . (:foreground "LightGray" :weight bold)) 1249 | )) 1250 | ;;;;; Press C-c r to select the log file from the list of log files for insert todos with C-c t 1251 | ;% The function will then search for the heading with the specified tag and append the TODO item at the bottom of the TODO list under that heading. 1252 | ;% (setq my-org-refile-directories '( 1253 | ;% ("/Users/blaine/gtd/tasks/JournalArticles.org" :maxlevel . 3) 1254 | ;% ("/Users/blaine/gtd/tasks/Proposals.org" :maxlevel . 3) 1255 | ;% ("/Users/blaine/0598tenRulesWritingLog/cb/log0598tsrWritingLog.org" :maxlevel . 3) 1256 | ;% )) 1257 | 1258 | ;;;;;; Include the writing project log files as refile targets 1259 | ;% A list can be stored in a private file 1260 | ;% The TODOs are at the 3rd headline level. 1261 | ;% Initialize private refile targets as an empty list. 1262 | (setq private-refile-targets '()) 1263 | ;; Load private refile targets from an external file if it exists. 1264 | (let ((private-file (expand-file-name "private-refile-targets.el" user-emacs-directory))) 1265 | (when (file-exists-p private-file) 1266 | (load private-file))) 1267 | ;% Public refile target: 1268 | (setq public-refile-target 1269 | '(( "/Users/blaine/1019NIHemofat/cb/log1019.org" :maxlevel . 3))) 1270 | ;% Combine the private and public refile targets. The private version could be the above empty list. 1271 | (setq my-org-refile-targets (append private-refile-targets public-refile-target)) 1272 | (defun my-select-org-refile-target () 1273 | "Prompt for an org refile target from a list of directories." 1274 | (interactive) 1275 | (let ((target (completing-read "Select refile target: " my-org-refile-targets))) 1276 | (setq my-org-refile-targets `((,target :maxlevel . 3))))) 1277 | (setq org-refile-use-outline-path 'file) 1278 | (global-set-key (kbd "C-c r") 'my-select-org-refile-target) 1279 | ;;;;;; Append TODO item at bottom of TODO list in writing project log file. 1280 | ;% I like to use project ID number and 'do' at the tag. 1281 | (defun my-append-todo-to-heading (tag todo-text) 1282 | "Append TODO-TEXT to the bottom of a TODO list under a heading with TAG. Enter the tag without the flanking colons." 1283 | (interactive "sTag: \nsTODO: ") 1284 | (save-excursion 1285 | (goto-char (point-min)) 1286 | (if (re-search-forward (format "^\*+ .* :%s:" tag) nil t) 1287 | (progn 1288 | (org-end-of-subtree t t) 1289 | (insert (format "*** TODO %s \n" todo-text))) 1290 | (message "Heading with tag %s not found" tag)))) 1291 | (global-set-key (kbd "C-c t") 'my-append-todo-to-heading) 1292 | (message "Finished refile target configuration.") 1293 | ;;;;; Customized agenda views 1294 | ;% 1295 | ;% These are my customized agenda views by project. 1296 | ;% The letter is the last parameter. 1297 | ;% For example, enter ~C-c a b~ and then enter 402 at the prompt to list all active tasks related to 402 tasks. 1298 | ;% 1299 | ;% I learned about this approach [[https://tlestang.github.io/blog/keeping-track-of-tasks-and-projects-using-emacs-and-org-mode.html][here]]. 1300 | ;% 1301 | ;% The CATEGORY keyword resides inside of a Properties drawer. 1302 | ;% The drawers are usually closed. 1303 | ;% I am having trouble opening my drawers in may org files. 1304 | ;% In addition, I do not want to have to add a drawer to each TODO. 1305 | ;% 1306 | ;% I am loving Tags now. 1307 | ;% I may switch to using Tags because they are visible in org files. 1308 | ;% I tried and they are not leading to the expect list of TODOs in org-agenda. 1309 | ;% I am stumped. 1310 | ;% 1311 | ;% In the meantime, enter ~C-c \~ inside JournalArticles.org to narrow the focus to the list of TODOs or enter ~C-c i b~ to get an indirect buffer. 1312 | (setq org-agenda-custom-commands 1313 | '( 1314 | ("b" 1315 | "List of all active 1019 tasks." 1316 | tags-todo 1317 | "1019\"/TODO|INITIATED|WAITING") 1318 | ("c" 1319 | "List of all active 523 RNA-drug crystallization review paper tasks." 1320 | tags-todo 1321 | "CATEGORY=\"523\"/TODO|INITIATED|WAITING") 1322 | ("d" 1323 | "List of all active 0527CrystalDetectionByAI tasks." 1324 | tags-todo 1325 | "CATEGORY=\"527\"/TODO|INITIATED|WAITING") 1326 | ("e" 1327 | "List of all active 0032RNA32merEditingSite tasks." 1328 | tags-todo 1329 | "CATEGORY=\"32\"/TODO|INITIATED|WAITING") 1330 | 1331 | ("l" 1332 | "List of all active 0598tenRulesWritingProjectLog tasks." 1333 | tags-todo 1334 | "CATEGORY=\"598\"/TODO|INITIATED|WAITING") 1335 | ("e" 1336 | "List of all active 0495emofat4mx tasks." 1337 | tags-todo 1338 | "CATEGORY=\"495\"/TODO|INITIATED|WAITING") 1339 | ("r" 1340 | "List of all active 0466ReproDSD tasks." 1341 | tags-todo 1342 | "CATEGORY=\"515\"/TODO|INITIATED|WAITING") 1343 | ("s" 1344 | "List of all active 0515CrystallizationSupports tasks." 1345 | tags-todo 1346 | "CATEGORY=\"515\"/TODO|INITIATED|WAITING") 1347 | ("P" 1348 | "List of all projects" 1349 | tags 1350 | "LEVEL=2/PROJ"))) 1351 | ;;;; Remap the change priority keys to use the UP or DOWN key 1352 | ;; (define-key org-mode-map (kbd "C-c ") 'org-priority-up) 1353 | ;; (define-key org-mode-map (kbd "C-c ") 'org-priority-down) 1354 | (message "Finished org-agenda custum command configuration.") 1355 | (message "Started org-cc.") 1356 | ;% ;;;; org-cc 1357 | ;% ;% Context clues 1358 | ;% ;% source https://github.com/durableOne/org-cc 1359 | ;% (use-package org-cc 1360 | ;% :straight (org-cc :type git :host github :repo "durableOne/org-cc") 1361 | ;% :ensure nil 1362 | ;% :after org 1363 | ;% :custom 1364 | ;% (org-cc-directory (concat org-directory "org-cc")) ;; subdirectory of the heading's attachment directory 1365 | ;% (org-cc-days 14) 1366 | ;% :init 1367 | ;% (add-hook 'org-clock-in-hook #'org-cc-display-notes) 1368 | ;% ) 1369 | ;% (global-set-key (kbd "C-c k") 'org-cc-edit-cc-file) 1370 | ;% (global-set-key (kbd "C-c x") 'org-cc-display-notes) 1371 | ;% (message "Finished org-cc.") 1372 | (message "Started org-noter configuration.") 1373 | ;;;; org-noter 1374 | ;% This package synchronizes notes on documents, such as PDFs, while keeping the notes themselves in an Org-mode file. 1375 | ;% The external notes are in a org document with all the features that Org has. 1376 | ;% Enter `i` in the document buffer to save the location of the note. 1377 | ;% Workds best with pdf-tools and org-ref. 1378 | ;% Integrated here with citar. 1379 | ;% 1380 | ;% - Open a new reference note with (citar0-open-notes) 1381 | ;% Open the document in Emacs. 1382 | ;% M-x org-noter 1383 | 1384 | ;; Use straight to install org-noter 1385 | (straight-use-package 'org-noter) 1386 | 1387 | ;; Set the org-noter notes search path 1388 | (setq org-noter-notes-search-path '("~/org-noter-notes/")) 1389 | ;% (message "Started org-noter configuration.") 1390 | ;% (use-package org-noter 1391 | ;% :straight (org-noter :type git :host github :repo "weirdNox/org-noter") 1392 | ;% :config 1393 | ;% ;; Your org-noter config ........ 1394 | ;% (require 'org-noter-pdftools)) 1395 | ;% 1396 | ;% (use-package org-pdftools 1397 | ;% :straight (org-pdftools :type git :host github :repo "fuxialexander/org-pdftools") 1398 | ;% :hook (org-mode . org-pdftools-setup-link)) 1399 | ;% 1400 | ;% (use-package org-noter-pdftools 1401 | ;% :straight (org-noter-pdftools :type git :host github :repo "fuxialexander/org-pdftools") 1402 | ;% :after org-noter 1403 | ;% :config 1404 | ;% ;; Add a function to ensure precise note is inserted 1405 | ;% (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions) 1406 | ;% (interactive "P") 1407 | ;% (org-noter--with-valid-session 1408 | ;% (let ((org-noter-insert-note-no-questions (if toggle-no-questions 1409 | ;% (not org-noter-insert-note-no-questions) 1410 | ;% org-noter-insert-note-no-questions)) 1411 | ;% (org-pdftools-use-isearch-link t) 1412 | ;% (org-pdftools-use-freepointer-annot t)) 1413 | ;% (org-noter-insert-note (org-noter--get-precise-info))))) 1414 | ;% 1415 | ;% ;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf 1416 | ;% (defun org-noter-set-start-location (&optional arg) 1417 | ;% "When opening a session with this document, go to the current location. 1418 | ;% With a prefix ARG, remove start location." 1419 | ;% (interactive "P") 1420 | ;% (org-noter--with-valid-session 1421 | ;% (let ((inhibit-read-only t) 1422 | ;% (ast (org-noter--parse-root)) 1423 | ;% (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive)))) 1424 | ;% (with-current-buffer (org-noter--session-notes-buffer session) 1425 | ;% (org-with-wide-buffer 1426 | ;% (goto-char (org-element-property :begin ast)) 1427 | ;% (if arg 1428 | ;% (org-entry-delete nil org-noter-property-note-location) 1429 | ;% (org-entry-put nil org-noter-property-note-location 1430 | ;% (org-noter--pretty-print-location location)))))))) 1431 | ;% (with-eval-after-load 'pdf-annot 1432 | ;% (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note))) 1433 | ;% (message "Finished org-noter configuration.") 1434 | 1435 | 1436 | ;%(use-package org-noter 1437 | ;% :straight (org-noter :type git :host github :repo "weirdNox/org-noter") 1438 | ;% :after org 1439 | ;% :config 1440 | ;% ;% Your org-noter config ........ 1441 | ;% :config 1442 | ;% (setq 1443 | ;% org_notes (concat (getenv "HOME") "/org-roam/") 1444 | ;% zot_bib (concat (getenv "HOME") "/Documents/global.bib") 1445 | ;% org-directory org_notes 1446 | ;% deft-directory org_notes 1447 | ;% org-roam-directory org_notes 1448 | ;% ;% keep an empty line between headings and content in Org file 1449 | ;% org-noter-separate-notes-from-heading t) 1450 | ;% (require 'org-noter-pdftools)) 1451 | 1452 | ;%(use-package org-pdftools 1453 | ;% :straight (org-pdftools :type git :host github :repo "fuxialexander/org-pdftools") 1454 | ;% :hook (org-mode . org-pdftools-setup-link)) 1455 | ;% 1456 | ;%(use-package org-noter-pdftools 1457 | ;% :after org-noter 1458 | ;% :config 1459 | ;% ;% Add a function to ensure precise note is inserted 1460 | ;% (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions) 1461 | ;% (interactive "P") 1462 | ;% (org-noter--with-valid-session 1463 | ;% (let ((org-noter-insert-note-no-questions (if toggle-no-questions 1464 | ;% (not org-noter-insert-note-no-questions) 1465 | ;% org-noter-insert-note-no-questions)) 1466 | ;% (org-pdftools-use-isearch-link t) 1467 | ;% (org-pdftools-use-freepointer-annot t)) 1468 | ;% (org-noter-insert-note (org-noter--get-precise-info))))) 1469 | ;% 1470 | ;% ;% fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf 1471 | ;% (defun org-noter-set-start-location (&optional arg) 1472 | ;% "When opening a session with this document, go to the current location. 1473 | ;%With a prefix ARG, remove start location." 1474 | ;% (interactive "P") 1475 | ;% (org-noter--with-valid-session 1476 | ;% (let ((inhibit-read-only t) 1477 | ;% (ast (org-noter--parse-root)) 1478 | ;% (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive)))) 1479 | ;% (with-current-buffer (org-noter--session-notes-buffer session) 1480 | ;% (org-with-wide-buffer 1481 | ;% (goto-char (org-element-property :begin ast)) 1482 | ;% (if arg 1483 | ;% (org-entry-delete nil org-noter-property-note-location) 1484 | ;% (org-entry-put nil org-noter-property-note-location 1485 | ;% (org-noter--pretty-print-location location)))))))) 1486 | ;% (with-eval-after-load 'pdf-annot 1487 | ;% (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note))) 1488 | ;%;;;; pdf-tools-org-noter-helpers 1489 | ;%(use-package pdf-tools-org-noter-helpers 1490 | ;% :straight (pdf-tools-org-noter-helpers :type git :host github :repo "analyticd/pdf-tools-org-noter-helpers")) 1491 | (message "Finished org-noter configuration.") 1492 | (message "Start org-pomodoro configuration.") 1493 | ;;;; org-pomodoro 1494 | (use-package org-pomodoro 1495 | :straight (org-pomodoro :type git :host github :repo "marcinkoziej/org-pomodoro") 1496 | :commands (org-pomodoro) 1497 | :config 1498 | (setq alert-user-configuration (quote ((((:category . "org-pomodoro")) libnotify nil))))) 1499 | ;% add hook to enable automated start of the next pom after a break. 1500 | ;% Source: https://github.com/marcinkoziej/org-pomodoro/issues/32 1501 | ;% (add-hook 'org-pomodoro-break-finished-hook 1502 | ;% (lambda () 1503 | ;% (interactive) 1504 | ;% (point-to-register 1) 1505 | ;% (org-clock-goto) 1506 | ;% (org-pomodoro '(25)) 1507 | ;% (register-to-point 1) 1508 | ;% (shell-command-to-string "open -a tomighty.app") 1509 | ;% )) 1510 | (use-package sound-wav) 1511 | (setq org-pomodoro-ticking-sound-p nil) 1512 | (setq org-pomodoro-ticking-sound-states '(:pomodoro :short-break :long-break)) 1513 | (setq org-pomodoro-ticking-sound-states '(:pomodoro)) 1514 | (setq org-pomodoro-ticking-frequency 1) 1515 | (setq org-pomodoro-audio-player "mplayer") 1516 | (setq org-pomodoro-finished-sound-args "-volume 0.9") 1517 | (setq org-pomodoro-long-break-sound-args "-volume 0.9") 1518 | (setq org-pomodoro-short-break-sound-args "-volume 0.9") 1519 | (setq org-pomodoro-ticking-sound-args "-volume 0.3") 1520 | (global-set-key (kbd "C-c o") 'org-pomodoro) 1521 | (message "Finished org-pomodoros configuration.") 1522 | (message "Start configuration of org-ref.") 1523 | ;;;; org-ref 1524 | ;% Set the case of the Author and Title to Capitalize with customize. 1525 | (use-package org-ref 1526 | :straight (org-ref :type git :host github :repo "jkitchin/org-ref") 1527 | :init 1528 | (use-package bibtex) 1529 | (setq bibtex-autokey-year-length 4 1530 | bibtex-autokey-name-year-separator "" 1531 | bibtex-autokey-year-title-separator "" 1532 | bibtex-autokey-titleword-separator "" 1533 | bibtex-autokey-titlewords 9 1534 | bibtex-autokey-titlewords-stretch 9 1535 | bibtex-autokey-titleword-length 15) 1536 | ;% H is the hyper key. I have bound H to Fn. For the MacAlly keyboard, it is bound to right-command. 1537 | (define-key bibtex-mode-map (kbd "H-b") 'org-ref-bibtex-hydra/body) 1538 | ;% (use-package org-ref-ivy) 1539 | (setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body 1540 | org-ref-insert-cite-function 'org-ref-cite-insert-ivy 1541 | org-ref-insert-label-function 'org-ref-insert-label-link 1542 | org-ref-insert-ref-function 'org-ref-insert-ref-link 1543 | org-ref-cite-onclick-function (lambda (_) (org-ref-citation-hydra/body))) 1544 | ; (use-package org-ref-arxiv) 1545 | ; (use-package org-ref-pubmed) 1546 | ; (use-package org-ref-wos) 1547 | ) 1548 | (message "Finished configuration of org-ref.") 1549 | (message "Start bibtex-completion-bibliography configuration.") 1550 | (setq bibtex-completion-bibliography '("/Users/blaine/Documents/global.bib") 1551 | bibtex-completion-library-path '("/Users/blaine/0papersLabeled/" "/Users/blaine/0booksLabeled/") 1552 | bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 1553 | bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 1554 | bibtex-completion-additional-search-fields '(keywords) 1555 | bibtex-completion-display-formats 1556 | '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 1557 | (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 1558 | (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 1559 | (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 1560 | (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 1561 | bibtex-completion-pdf-open-function 1562 | (lambda (fpath) 1563 | (call-process "open" nil 0 nil fpath))) 1564 | 1565 | (setq bibtex-autokey-year-length 4 1566 | bibtex-autokey-name-year-separator "-" 1567 | bibtex-autokey-year-title-separator "-" 1568 | bibtex-autokey-titleword-separator "-" 1569 | bibtex-autokey-titlewords 2 1570 | bibtex-autokey-titlewords-stretch 1 1571 | bibtex-autokey-titleword-length 5) 1572 | (message "Finished bibtex-completion-bibliography configuration.") 1573 | (message "Start org-roam configurations") 1574 | ;;;; Basic org-roam config 1575 | (use-package org-roam 1576 | :straight (org-roam 1577 | :type git 1578 | :host github 1579 | :repo "org-roam/org-roam") 1580 | :init 1581 | (setq org-roam-v2-ack t) ;; If you're using Org-roam v2 1582 | :custom 1583 | (org-roam-directory (file-truename "/Users/blaine/org-roam/")) 1584 | :bind (("C-c n l" . org-roam-buffer-toggle) 1585 | ("C-c n f" . org-roam-node-find) 1586 | ("C-c n g" . org-roam-graph) 1587 | ("C-c n i" . org-roam-node-insert) 1588 | ("C-c n c" . org-id-get-create) 1589 | ;; Dailies 1590 | ("C-c n j" . org-roam-dailies-capture-today)) 1591 | :config 1592 | ;; Ensure C-c n is a prefix key 1593 | (define-prefix-command 'org-roam-prefix-map) 1594 | (global-set-key (kbd "C-c n") 'org-roam-prefix-map) 1595 | ;; If you're using a vertical completion framework, you might want a more informative completion interface 1596 | (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 1597 | (org-roam-db-autosync-mode) 1598 | (org-roam-ui-mode)) 1599 | ;% If using org-roam-protocol 1600 | ;% (use-package org-roam-protocol 1601 | ;% :straight t)) 1602 | ;% Following https://jethrokuan.github.io/org-roam-guide/ 1603 | (message "Finished org-roam configurations") 1604 | (message "Start org-roam-capture template configurations.") 1605 | ; (setq org-roam-capture-templates 1606 | ; '(("p" "permanent" plain 1607 | ; "%?" 1608 | ; :if-new (file+head "main/${slug}.org" "#+title: ${title}\n\n* Note type: permanent\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 1609 | ; :immediate-finish t 1610 | ; :unnarrowed t) 1611 | ; ;; citar literature note 1612 | ; ;% ("n" "literature note" plain 1613 | ; ;% "%?" 1614 | ; ;% :target (file+head "%(expand-file-name (or citar-org-roam-subdir \"\") org-roam-directory)/${citar-citekey}.org" 1615 | ; ;% "#+title: ${citar-citekey}.\n Article title: ${note-title}.\n Year: ${citar-year} \n Keywords: ${citar-keywords} \n Note type: literature\n\n\n#+created: %U\n#+last_modified: %U\n\n") 1616 | ; ;% :unnarrowed t) 1617 | ; ("r" "reference" plain "%?" 1618 | ; :if-new 1619 | ; (file+head "reference/${title}.org" "#+title: ${title}\n\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 1620 | ; :immediate-finish t 1621 | ; :unnarrowed t) 1622 | ; ("l" "clipboard" plain #'org-roam-capture--get-point "%i%a" 1623 | ; :file-name "%<%Y%m%d%H%M%S>-${slug}" 1624 | ; :head "#+title: ${title}\n#+created: %u\n#+last_modified: %U\n#+ROAM_TAGS: %?" 1625 | ; :unnarrowed t 1626 | ; :prepend t 1627 | ; :jump-to-captured t) 1628 | ; ;% Vidianos G's config with ivy-bibtex 1629 | ; ("v" "bibliography reference" plain 1630 | ; "%?" 1631 | ; : if-new 1632 | ; (file+head "ref/${citekey}.org" "#+title: ${title}\n 1633 | ; ,#+filetags: ${entry-type} 1634 | ; - keywords :: ${keywords} 1635 | ; - tags :: 1636 | ; 1637 | ; ,* Analysis of ${entry-type} by ${author} 1638 | ; 1639 | ; 1640 | ; 1641 | ; * References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n 1642 | ; :PROPERTIES: 1643 | ; :URL: ${Url} 1644 | ; :NOTER_DOCUMENT: ${file} 1645 | ; :NOTER_PAGE: 1646 | ; :END:") 1647 | ; :unnarrowed t 1648 | ; :jump-to-captured t) 1649 | ; ("b" "bibliography notes" plain ; Org-noter integration 1650 | ; (file "~/org-roam/references/notes/notes-template.org") 1651 | ; :target (file+head "references/notes/${citekey}.org" 1652 | ; "#+title: ${title}\n :article:\n\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 1653 | ; :empty-lines 1) 1654 | ; ("a" "article" plain "%?" 1655 | ; :if-new 1656 | ; (file+head "articles/${title}.org" "#+title: ${title}\n :article:\n\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 1657 | ; :immediate-finish t 1658 | ; :unnarrowed t))) 1659 | ; (setq org-roam-node-display-template 1660 | ; (concat "${type:15} ${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 1661 | ;% Writing technical documents requires us to write in paragraphs, 1662 | ;% whereas org mode by default is intended to be used as an outliner, 1663 | ;% to get around this problem, setting up org-export to preserve line breaks is useful 1664 | ;% (setq org-export-preserve-breaks t) 1665 | (message "Finished org-roam configurations.") 1666 | (message "Start org-roam-bibtex.") 1667 | ; (use-package org-roam-bibtex 1668 | ; :straight (org-roam-bibtex :type git :host github :repo "org-roam/org-roam-bibtex") 1669 | ; :after org-roam 1670 | ; :config 1671 | ; (use-package org-ref)) ; optional: if using Org-ref v2 or v3 citation links 1672 | (use-package org-roam-bibtex 1673 | :straight (org-roam-bibtex :type git :host github :repo "org-roam/org-roam-bibtex") 1674 | :after org-roam 1675 | :config 1676 | (use-package org-ref)) 1677 | (message "Finished org-roam-bibtex.") 1678 | (message "Start toggle-state-at-point for use with images and equations.") 1679 | ;% Place point on link to image. Left-click to display image in another buffer. Enter C-c t to display the code of the link for easy editing. 1680 | ;% Place point on equation. Enter C-c t to render it with MathJax. Left click on the rendered equation to switch back to the code. 1681 | ;% Put multiline code from mathpix between double dollar signs and treat as being on one line. 1682 | ;% This trick does not work with the equation environment compressed to one line. You have to use M-x math-preview-region. 1683 | ;% I modified this from https://emacs.stackexchange.com/questions/59151/how-can-i-switch-a-preview-image-in-an-org-mode-buffer-to-its-source-block 1684 | ;% 1685 | ;% I ran out of time to determine how to render an active region. I need to find the analog of the latex-fragment: 1686 | ;% ('latex-???? (math-preview-region)) 1687 | ;% ???? has to be some kind of an org-element-type. org-latex-section does not work. 1688 | ;% This would enable using this application of the math-preview-region to render equation environments. 1689 | (defun bhmm/toggle-state-at-point () 1690 | (interactive) 1691 | (let ((ctx (org-element-context))) 1692 | (pcase (org-element-type ctx) 1693 | ('link (org-toggle-link-display)) 1694 | ('latex-fragment (math-preview-at-point))))) 1695 | 1696 | ;% (define-key org-mode-map (kbd "C-c t") #'bhmm/toggle-state-at-point) 1697 | (message "End toggle-state-at-point for use with images and equations.") 1698 | (message "Start ox-typst.") 1699 | (use-package ox-typst 1700 | :straight (ox-typst :type git :host github :repo "jmpunkt/ox-typst") 1701 | :after org) 1702 | (message "Finished ox-typst.") 1703 | (message "Finished O package configurations") 1704 | 1705 | (message "Start P package configurations") 1706 | ;;; P 1707 | ;;;; pdf-tools 1708 | ;% Emacs has a built-in DocView package that can display PDFs but it is not as versatile as pdf-tools. 1709 | ;% You will likely by prompted to run pdf-tools-install to compile it. 1710 | ;% It is needed to be able to annotate PDF from inside Emacs. 1711 | ;% I have not gotten that far. 1712 | ;% (use-package pdf-tools 1713 | ;% :straight t 1714 | ;% :pin manual ;; manually update 1715 | ;% :config 1716 | ;% ;; initialise 1717 | ;% (pdf-tools-install) 1718 | ;% ;; open pdfs scaled to fit width 1719 | ;% (setq-default pdf-view-display-size 'fit-width) 1720 | ;% ;; use normal isearch 1721 | ;% (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward) 1722 | ;% :custom 1723 | ;% (pdf-annot-activate-created-annotations t "automatically annotate highlights")) 1724 | 1725 | ;% source https://github.com/malb/emacs.d/blob/master/malb.org#pdf-viewer 1726 | ;% Learned about this from Julien during Berln Emacs Meetup Nev. 27, 2024. 1727 | (use-package pdf-tools 1728 | :straight 1729 | :magic ("%PDF" . pdf-view-mode) 1730 | :after (org tex) 1731 | :config (progn 1732 | (pdf-tools-install) 1733 | (setq-default pdf-view-display-size 'fit-page) 1734 | 1735 | (require 'pdf-annot) 1736 | 1737 | (setq pdf-annot-default-annotation-properties 1738 | `((t (label . "M")) 1739 | (text (icon . "Note") 1740 | (color . "#dc322f")) 1741 | (highlight (color . "#fef3d5")) 1742 | (squiggly (color . "#dc322f")) 1743 | (strike-out(color . "#dc322f")) 1744 | (underline (color . "#268bd2")))) 1745 | 1746 | (setq pdf-view-resize-factor 1.1 1747 | pdf-annot-activate-created-annotations t 1748 | pdf-view-midnight-invert nil 1749 | pdf-misc-print-programm "gtklp") 1750 | 1751 | (add-hook 'pdf-annot-list-mode-hook #'pdf-annot-list-follow-minor-mode) 1752 | 1753 | (defun malb/pdf-extract-table (&optional format) 1754 | (let* ((format- (upcase (or format "CSV"))) 1755 | (pdf-filename (buffer-file-name)) 1756 | (txt-filename (make-temp-name "/tmp/tabula-")) 1757 | (buffer (generate-new-buffer 1758 | (generate-new-buffer-name (format "*tabular<%s>*" 1759 | (file-name-base pdf-filename)))))) 1760 | (shell-command (format "java -jar %s -f %s -p %d -o \"%s\" \"%s\"" 1761 | malb/tabular-jar 1762 | format- 1763 | (pdf-view-current-page) 1764 | txt-filename 1765 | pdf-filename) 1766 | nil) 1767 | (pop-to-buffer buffer) 1768 | (insert-file-contents txt-filename) 1769 | (cond 1770 | ((eq format nil) (progn 1771 | (org-mode) 1772 | (call-interactively 'mark-whole-buffer) 1773 | (call-interactively 'org-table-convert-region))) 1774 | ((string-equal format "JSON") (progn 1775 | (json-mode) 1776 | (json-pretty-print-buffer)))) 1777 | (delete-file txt-filename))) 1778 | 1779 | (defun malb/pdf-extract-text () 1780 | (let* ((pdf-filename (buffer-file-name)) 1781 | (txt-filename (make-temp-name "/tmp/tabula-")) 1782 | (buffer (generate-new-buffer 1783 | (generate-new-buffer-name (format "*pdftotext<%s>*" 1784 | (file-name-base pdf-filename)))))) 1785 | (shell-command (format "pdftotext -layout -nopgbrk \"%s\" \"%s\"" 1786 | pdf-filename txt-filename) 1787 | nil) 1788 | (pop-to-buffer buffer) 1789 | (insert-file-contents txt-filename) 1790 | (delete-file txt-filename))) 1791 | 1792 | (defun malb/pdf-view-llncs-from-bounding-box (arg &optional window) 1793 | "Set the height from the page's bounding-box." 1794 | (interactive "P") 1795 | (let* ((bb (pdf-cache-boundingbox (pdf-view-current-page window))) 1796 | (h-margin (max (if arg 0.35 0.28) (or pdf-view-bounding-box-margin 0.0))) 1797 | (w-margin (max 0.05 (or pdf-view-bounding-box-margin 0.0))) 1798 | (slice (list (- (nth 0 bb) 1799 | (/ h-margin 2.0)) 1800 | (- (nth 1 bb) 1801 | (/ w-margin 2.0)) 1802 | (+ (- (nth 2 bb) (nth 0 bb)) 1803 | h-margin) 1804 | (+ (- (nth 3 bb) (nth 1 bb)) 1805 | w-margin)))) 1806 | (apply 'pdf-view-set-slice 1807 | (append slice (and window (list window)))))) 1808 | 1809 | (defun pdf-tools-org-edges-to-region (edges) 1810 | "Attempt to get 4-entry region \(LEFT TOP RIGHT BOTTOM\) from several EDGES. 1811 | We need this to import annotations and to get marked-up text, because 1812 | annotations are referenced by its edges, but functions for these tasks 1813 | need region." 1814 | (let ((left0 (nth 0 (car edges))) 1815 | (top0 (nth 1 (car edges))) 1816 | (bottom0 (nth 3 (car edges))) 1817 | (top1 (nth 1 (car (last edges)))) 1818 | (right1 (nth 2 (car (last edges)))) 1819 | (bottom1 (nth 3 (car (last edges)))) 1820 | (n (safe-length edges))) 1821 | ;; we try to guess the line height to move 1822 | ;; the region away from the boundary and 1823 | ;; avoid double lines 1824 | (list left0 1825 | (+ top0 (/ (- bottom0 top0) 3)) 1826 | right1 1827 | (- bottom1 (/ (- bottom1 top1) 3))))) 1828 | 1829 | (defun malb/pdf-annot-export-as-org (compact) 1830 | "Export annotations to Org Buffer." 1831 | (interactive "P") 1832 | (let* ((annots (sort (pdf-annot-getannots) 'pdf-annot-compare-annotations)) 1833 | (source-buffer (current-buffer)) 1834 | (source-buffer-name (file-name-sans-extension (buffer-name))) 1835 | (source-file-name (buffer-file-name source-buffer)) 1836 | (target-buffer-name (format "*Notes for %s*" source-buffer-name)) 1837 | (target-buffer (get-buffer-create target-buffer-name))) 1838 | 1839 | (with-current-buffer target-buffer 1840 | (org-mode) 1841 | (erase-buffer) 1842 | (visual-fill-column-mode) 1843 | 1844 | (insert (format "#+title: Notes for %s\n" source-buffer-name)) 1845 | (insert (format "#+startup: indent\n\n")) 1846 | (insert (format "source: [[%s][%s]]\n\n" source-file-name source-buffer)) 1847 | 1848 | (mapc (lambda (annot) ;; traverse all annotations 1849 | (progn 1850 | (let ((page (cdr (assoc 'page annot))) 1851 | (highlighted-text 1852 | (if (pdf-annot-get annot 'markup-edges) 1853 | (let ((highlighted-text 1854 | (with-current-buffer source-buffer 1855 | (pdf-info-gettext (pdf-annot-get annot 'page) 1856 | (pdf-tools-org-edges-to-region 1857 | (pdf-annot-get annot 'markup-edges)))))) 1858 | (replace-regexp-in-string "\n" " " highlighted-text)) 1859 | nil)) 1860 | (note (pdf-annot-get annot 'contents))) 1861 | 1862 | (when (or highlighted-text (> (length note) 0)) 1863 | (insert (if compact "- " "* ")) 1864 | (insert (format "page %s" page)) 1865 | 1866 | (when highlighted-text 1867 | (insert (if compact (format ": “%s” " highlighted-text) 1868 | (concat "\n\n#+begin_quote\n" 1869 | highlighted-text 1870 | "\n#+end_quote")))) 1871 | (if (> (length note) 0) 1872 | (insert (if compact (format " %s\n" note) 1873 | (format "\n\n%s\n\n" note))) 1874 | (insert (if compact "\n" "\n\n"))))))) 1875 | (cl-remove-if 1876 | (lambda (annot) (member (pdf-annot-get-type annot) (list 'link))) 1877 | annots)) 1878 | ) 1879 | (pop-to-buffer target-buffer '(display-buffer-pop-up-window)))) 1880 | 1881 | (defun malb/pdf-annot-export-as-md (compact) 1882 | "Export annotations to Makrdown buffer." 1883 | (interactive "P") 1884 | (let* ((annots (sort (pdf-annot-getannots) 'pdf-annot-compare-annotations)) 1885 | (source-buffer (current-buffer)) 1886 | (source-buffer-name (file-name-sans-extension (buffer-name))) 1887 | (source-file-name (buffer-file-name source-buffer)) 1888 | (target-buffer-name (format "*Notes for %s*" source-buffer-name)) 1889 | (target-buffer (get-buffer-create target-buffer-name))) 1890 | (with-current-buffer target-buffer 1891 | (markdown-mode) 1892 | (erase-buffer) 1893 | (visual-fill-column-mode) 1894 | 1895 | (insert (format "---\ntitle: Notes for %s\n---\n\n" source-buffer-name)) 1896 | (insert (format "source: [%s](%s)\n\n" source-buffer source-file-name)) 1897 | (mapc (lambda (annot) ;; traverse all annotations 1898 | (progn 1899 | (let ((page (cdr (assoc 'page annot))) 1900 | (highlighted-text 1901 | (if (pdf-annot-get annot 'markup-edges) 1902 | (let ((highlighted-text 1903 | (with-current-buffer source-buffer 1904 | (pdf-info-gettext (pdf-annot-get annot 'page) 1905 | (pdf-tools-org-edges-to-region 1906 | (pdf-annot-get annot 'markup-edges)))))) 1907 | (replace-regexp-in-string "\n" " " highlighted-text)) 1908 | nil)) 1909 | (note (pdf-annot-get annot 'contents))) 1910 | 1911 | (when (or highlighted-text (> (length note) 0)) 1912 | (insert (if compact "- " "On ")) 1913 | (insert (format "page %s" page)) 1914 | 1915 | (when highlighted-text 1916 | (insert (if compact (format ": “%s” " highlighted-text) 1917 | (concat ": \n> " 1918 | (replace-regexp-in-string "\n" "\n> " highlighted-text) 1919 | "\n")))) 1920 | (if (> (length note) 0) 1921 | (insert (if compact (format " %s\n" note) 1922 | (format "\n\n%s\n\n" note))) 1923 | (insert (if compact "\n" "\n\n"))))))) 1924 | (cl-remove-if 1925 | (lambda (annot) (member (pdf-annot-get-type annot) (list 'link))) 1926 | annots))) 1927 | (pop-to-buffer target-buffer '(display-buffer-pop-up-window)))) 1928 | 1929 | (defhydra malb/hydra-pdf-extract (:color blue) 1930 | " 1931 | Org: _o_ compact _O_ normal _t_ table 1932 | Markdown: _m_ compact _M_ normal 1933 | Other: _p_ plain _c_ csv table _j_ json table _x_ ocr 1934 | " 1935 | ("o" (lambda () (interactive) (malb/pdf-annot-export-as-org 1))) 1936 | ("O" malb/pdf-annot-export-as-org) 1937 | ("m" (lambda () (interactive) (malb/pdf-annot-export-as-md 1))) 1938 | ("M" malb/pdf-annot-export-as-md) 1939 | ("c" (lambda () (interactive) (malb/pdf-extract-table "CSV"))) 1940 | ("j" (lambda () (interactive) (malb/pdf-extract-table "JSON"))) 1941 | ("t" (lambda () (interactive) (malb/pdf-extract-table))) 1942 | ("p" (lambda () (interactive) (malb/pdf-extract-text))) 1943 | ("x" (lambda () (interactive) (start-process (format "ocr %s" buffer-file-name) 1944 | nil "ocrmypdf" buffer-file-name buffer-file-name))) 1945 | ("q" nil "cancel")) 1946 | 1947 | (bind-key "s h" #'malb/pdf-view-llncs-from-bounding-box pdf-view-mode-map) 1948 | (bind-key "D" #'dedicated-mode pdf-view-mode-map) 1949 | (bind-key "x" #'malb/hydra-pdf-extract/body pdf-view-mode-map) 1950 | 1951 | (defun malb/pdf-annot-move (forward) 1952 | (let ((annot-list (with-current-buffer 1953 | (pdf-annot-get-buffer pdf-annot-edit-contents--annotation) 1954 | pdf-annot-list-buffer))) 1955 | (if annot-list 1956 | (progn 1957 | (pdf-annot-edit-contents-commit) 1958 | (if forward 1959 | (call-interactively 'tablist-next-line) 1960 | (call-interactively 'tablist-previous-line)) 1961 | (call-interactively 'tablist-find-entry)) 1962 | (let ((this nil) 1963 | (next nil) 1964 | (annotations 1965 | (sort (pdf-annot-getannots 1966 | nil nil 1967 | (cdar pdf-annot-edit-contents--annotation)) 1968 | 'pdf-annot-compare-annotations))) 1969 | (dolist (annot (if forward annotations (reverse annotations))) 1970 | (when (equal this t) 1971 | (setq next annot) 1972 | (setq this nil)) 1973 | (when (equal (pdf-annot-get-id annot) 1974 | (pdf-annot-get-id pdf-annot-edit-contents--annotation)) 1975 | (setq this t))) 1976 | (pdf-annot-edit-contents-finalize t) 1977 | (when next 1978 | (pdf-view-goto-page (pdf-annot-get next 'page)) 1979 | (pdf-annot-edit-contents next)))))) 1980 | 1981 | (defun malb/pdf-annot-next () 1982 | (interactive) 1983 | (malb/pdf-annot-move t)) 1984 | 1985 | (defun malb/pdf-annot-prev () 1986 | (interactive) 1987 | (malb/pdf-annot-move nil)) 1988 | 1989 | (defun malb/pdf-annot-yank-highlight () 1990 | (interactive) 1991 | (let* ((a pdf-annot-edit-contents--annotation) 1992 | (text 1993 | (replace-regexp-in-string 1994 | "\n" " " 1995 | (pdf-info-gettext 1996 | (pdf-annot-get a 'page) 1997 | (pdf-tools-org-edges-to-region (pdf-annot-get a 'markup-edges)) 1998 | 0 1999 | (pdf-annot-get a 'buffer))))) 2000 | (insert (format "\"%s\"" text)))) 2001 | 2002 | (bind-key "C-c C-n" 'malb/pdf-annot-next pdf-annot-edit-contents-minor-mode-map) 2003 | (bind-key "C-c C-p" 'malb/pdf-annot-prev pdf-annot-edit-contents-minor-mode-map) 2004 | (bind-key "C-c C-y" 'malb/pdf-annot-yank-highlight pdf-annot-edit-contents-minor-mode-map) 2005 | 2006 | (defun malb/do-to-pdf-view-buffer (fn) 2007 | (let ((cur-window (get-buffer-window))) 2008 | (dolist (window (window-list)) 2009 | (let ((buffer (window-buffer window))) 2010 | (with-current-buffer buffer 2011 | (when (eq major-mode 'pdf-view-mode) 2012 | (select-window window) 2013 | (call-interactively fn) 2014 | (select-window cur-window) 2015 | )))))) 2016 | 2017 | (defun malb/other-pdf-view-next-page () 2018 | (interactive) 2019 | (malb/do-to-pdf-view-buffer #'pdf-view-next-page)) 2020 | 2021 | (defun malb/other-pdf-view-prev-page () 2022 | (interactive) 2023 | (malb/do-to-pdf-view-buffer #'pdf-view-previous-page)) 2024 | 2025 | (bind-key "C->" #'malb/other-pdf-view-next-page org-mode-map) 2026 | (bind-key "C-<" #'malb/other-pdf-view-prev-page org-mode-map) 2027 | (bind-key "C->" #'malb/other-pdf-view-next-page LaTeX-mode-map) 2028 | (bind-key "C-<" #'malb/other-pdf-view-prev-page LaTeX-mode-map))) 2029 | (message "Finished P package configurations.") 2030 | 2031 | (message "Start S package configurations.") 2032 | ;;; S 2033 | ;;;; show-key 2034 | ;% Conflicts with tmux-pane 2035 | ;% #+BEGIN_COMMENT 2036 | ;% (straight-use-package 2037 | ;% '(showkey :type git :local-repo "~/e29fewpackages/manual-install/showkey")) 2038 | ;% (set-face-attribute 'default nil :height 240) 2039 | ;% (require 'showkey) 2040 | ;% #+END_COMMENT 2041 | ;;;; The emacsclient call depends on the daemon or `server-mode' 2042 | ;% The emacsclient depends either running the server or a daemon. 2043 | ;% The server is easier to manage than the daemon because you will 2044 | ;% find to find the daemon and kill it after updating the init.el file. 2045 | ;% This package is built-in, so it does not need to be installed by straight. 2046 | (use-package server 2047 | :ensure nil 2048 | :defer 1 2049 | :config 2050 | (unless (server-running-p) 2051 | (server-start))) 2052 | 2053 | ;;;; sqlite3 2054 | (use-package sqlite3 2055 | :straight t) 2056 | 2057 | (defun export-csv-to-qiterm (csv-file db-file table-name) 2058 | "Export selected rows from a CSV file to an SQLite database." 2059 | (interactive "fCSV file: \nfSQLite DB file: \nsTable name: ") 2060 | (let ((db (sqlite3-open db-file)) 2061 | (rows (with-temp-buffer 2062 | (insert-file-contents csv-file) 2063 | (split-string (buffer-string) "\n" t)))) 2064 | (dolist (row rows) 2065 | (let ((values (split-string row ","))) 2066 | (sqlite3-exec db 2067 | (format "INSERT INTO %s VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');" 2068 | table-name 2069 | (nth 0 values) 2070 | (nth 1 values) 2071 | (nth 2 values) 2072 | (nth 3 values) 2073 | (nth 4 values) 2074 | (nth 5 values) 2075 | (nth 6 values) 2076 | (nth 7 values))))) 2077 | (sqlite3-close db) 2078 | (message "Data successfully appended to %s" table-name))) 2079 | 2080 | ;; Usage example: 2081 | ;; (export-csv-to-qiterm "~/6233iterm/qiterm.csv" "~/6233iterm/qiterm.db" "qiterm") 2082 | 2083 | (message "Finished S package configurations.") 2084 | 2085 | 2086 | (message "Start T package configurations.") 2087 | ;;; T 2088 | ;;;; tmux-pane 2089 | (use-package tmux-pane 2090 | :straight (tmux-pane :type git :host github :repo "laishulu/emacs-tmux-pane")) 2091 | 2092 | 2093 | (use-package treemacs 2094 | :straight t 2095 | :defer t 2096 | :init 2097 | (with-eval-after-load 'winum 2098 | (define-key winum-keymap (kbd "M-0") #'treemacs-select-window)) 2099 | :config 2100 | (progn 2101 | (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) 2102 | treemacs-deferred-git-apply-delay 0.5 2103 | treemacs-directory-name-transformer #'identity 2104 | treemacs-display-in-side-window t 2105 | treemacs-eldoc-display 'simple 2106 | treemacs-file-event-delay 2000 2107 | treemacs-file-extension-regex treemacs-last-period-regex-value 2108 | treemacs-file-follow-delay 0.2 2109 | treemacs-file-name-transformer #'identity 2110 | treemacs-follow-after-init t 2111 | treemacs-expand-after-init t 2112 | treemacs-find-workspace-method 'find-for-file-or-pick-first 2113 | treemacs-git-command-pipe "" 2114 | treemacs-goto-tag-strategy 'refetch-index 2115 | treemacs-header-scroll-indicators '(nil . "^^^^^^") 2116 | treemacs-hide-dot-git-directory t 2117 | treemacs-indentation 2 2118 | treemacs-indentation-string " " 2119 | treemacs-is-never-other-window nil 2120 | treemacs-max-git-entries 5000 2121 | treemacs-missing-project-action 'ask 2122 | treemacs-move-files-by-mouse-dragging t 2123 | treemacs-move-forward-on-expand nil 2124 | treemacs-no-png-images nil 2125 | treemacs-no-delete-other-windows t 2126 | treemacs-project-follow-cleanup nil 2127 | treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) 2128 | treemacs-position 'left 2129 | treemacs-read-string-input 'from-child-frame 2130 | treemacs-recenter-distance 0.1 2131 | treemacs-recenter-after-file-follow nil 2132 | treemacs-recenter-after-tag-follow nil 2133 | treemacs-recenter-after-project-jump 'always 2134 | treemacs-recenter-after-project-expand 'on-distance 2135 | treemacs-litter-directories '("/node_modules" "/.venv" "/.cask") 2136 | treemacs-project-follow-into-home nil 2137 | treemacs-show-cursor nil 2138 | treemacs-show-hidden-files t 2139 | treemacs-silent-filewatch nil 2140 | treemacs-silent-refresh nil 2141 | treemacs-sorting 'alphabetic-asc 2142 | treemacs-select-when-already-in-treemacs 'move-back 2143 | treemacs-space-between-root-nodes t 2144 | treemacs-tag-follow-cleanup t 2145 | treemacs-tag-follow-delay 1.5 2146 | treemacs-text-scale nil 2147 | treemacs-user-mode-line-format nil 2148 | treemacs-user-header-line-format nil 2149 | treemacs-wide-toggle-width 70 2150 | treemacs-width 35 2151 | treemacs-width-increment 1 2152 | treemacs-width-is-initially-locked t 2153 | treemacs-workspace-switch-cleanup nil) 2154 | (treemacs-follow-mode t) 2155 | (treemacs-filewatch-mode t) 2156 | (treemacs-fringe-indicator-mode 'always) 2157 | (when treemacs-python-executable 2158 | (treemacs-git-commit-diff-mode t)) 2159 | (pcase (cons (not (null (executable-find "git"))) 2160 | (not (null treemacs-python-executable))) 2161 | (`(t . t) 2162 | (treemacs-git-mode 'deferred)) 2163 | (`(t . _) 2164 | (treemacs-git-mode 'simple))) 2165 | (treemacs-hide-gitignored-files-mode nil)) 2166 | :bind 2167 | (:map global-map 2168 | ("M-0" . treemacs-select-window) 2169 | ("C-x t 1" . treemacs-delete-other-windows) 2170 | ("C-x t t" . treemacs) 2171 | ("C-x t d" . treemacs-select-directory) 2172 | ("C-x t B" . treemacs-bookmark) 2173 | ("C-x t C-t" . treemacs-find-file) 2174 | ("C-x t M-t" . treemacs-find-tag))) 2175 | 2176 | ;;;; treemacs-protjectile 2177 | (use-package treemacs-projectile 2178 | :after (treemacs projectile) 2179 | :straight t) 2180 | ;;;; treemacs-icons-dired 2181 | (use-package treemacs-icons-dired 2182 | :hook (dired-mode . treemacs-icons-dired-enable-once) 2183 | :straight t) 2184 | 2185 | ;;;; treemacs-perspective 2186 | ;% treemacs-perspective if you use perspective.el vs. persp-mode 2187 | (use-package treemacs-persp 2188 | :after (treemacs persp-mode) ;;or perspective vs. persp-mode 2189 | :straight t 2190 | :config (treemacs-set-scope-type 'Perspectives)) 2191 | 2192 | ;;;; treemacs start on boot 2193 | (treemacs-start-on-boot) 2194 | (message "Finished T package configurations.") 2195 | 2196 | (message "Start U package configurations.") 2197 | ;;; U 2198 | ;;;; undo-tree 2199 | ;% The displayed undo tree is very helpful. 2200 | (use-package undo-tree 2201 | :straight t 2202 | :config 2203 | (global-undo-tree-mode 1)) 2204 | (message "Finished U package configurations.") 2205 | 2206 | 2207 | (message "Start V package configurations.") 2208 | ;;; V 2209 | ; ;;;; vterm 2210 | ; ;% One of five terminal type available in Emacs. 2211 | ; ;% See https://github.com/akermu/emacs-libvterm for configuration of init.el and .zshrc 2212 | ; (use-package vterm 2213 | ; :straight t) 2214 | ; (with-eval-after-load 'vterm 2215 | ; (define-key vterm-mode-map (kbd "C-q") #'vterm-send-next-key)) 2216 | ; 2217 | ;;;; vertico 2218 | (use-package vertico 2219 | :straight t 2220 | :init 2221 | (vertico-mode) 2222 | ;; Different scroll margin 2223 | ;; (setq vertico-scroll-margin 0) 2224 | ;; Show more candidates 2225 | (setq vertico-count 20) 2226 | ;; Grow and shrink the Vertico minibuffer 2227 | (setq vertico-resize t) 2228 | ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. 2229 | (setq vertico-cycle t)) 2230 | (message "Finished V package configurations.") 2231 | 2232 | 2233 | (message "Start W package configurations") 2234 | ;;;; wc-mode 2235 | ;% Add the path to the repo 2236 | (straight-use-package 2237 | '(wc-mode :type git :local-repo "~/e29fewpackages/manual-install/wc-mode")) 2238 | (global-set-key "\C-cw" 'wc-mode) 2239 | (wc-mode 1) 2240 | (message "Finished W package configurations.") 2241 | 2242 | ;;; X 2243 | (message "Start X package configurations.") 2244 | ;;;; Xenops 2245 | (use-package xenops 2246 | :straight (xenops :type git :host github :repo "dandavison/xenops")) 2247 | (add-hook 'latex-mode-hook #'xenops-mode) 2248 | (add-hook 'LaTeX-mode-hook #'xenops-mode) 2249 | (message "Finished X package configurations.") 2250 | 2251 | ;;; Y 2252 | (message "Start package configurations Y") 2253 | ;;;; yasnippet 2254 | ;% The popular snippet creator and manager package, 2255 | (use-package yasnippet 2256 | :straight t 2257 | :config 2258 | (yas-global-mode 1)) 2259 | (global-set-key "\C-o" 'yas-expand) 2260 | (global-set-key "\C-c y i" 'yas-insert-snippet) 2261 | (global-set-key "\C-c y n" 'yas-new-snippet) 2262 | 2263 | ;;;; A cool hydra for finding snippets at point. Invoke with C-c y. 2264 | (use-package hydra 2265 | :straight t 2266 | :defer 2 2267 | :bind ("C-c y" . hydra-yasnippet/body)) 2268 | 2269 | 2270 | (let ((hydra-file "~/e29fewpacakges/my-hydras/my-hydras.el")) 2271 | (when (file-exists-p hydra-file) 2272 | (load-file hydra-file))) 2273 | 2274 | ;;;; A popup menu for snippet selection 2275 | (use-package popup 2276 | :straight t) 2277 | ;; add some shortcuts in popup menu mode 2278 | (define-key popup-menu-keymap (kbd "M-n") 'popup-next) 2279 | (define-key popup-menu-keymap (kbd "TAB") 'popup-next) 2280 | (define-key popup-menu-keymap (kbd "M-p") 'popup-previous) 2281 | (defun yas/popup-isearch-prompt (prompt choices &optional display-fn) 2282 | (when (featurep 'popup) 2283 | (popup-menu* 2284 | (mapcar 2285 | (lambda (choice) 2286 | (popup-make-item 2287 | (or (and display-fn (funcall display-fn choice)) 2288 | choice) 2289 | :value choice)) 2290 | choices) 2291 | :prompt prompt 2292 | ;; start isearch mode immediately 2293 | :isearch t))) 2294 | (setq yas/prompt-functions '(yas/popup-isearch-prompt yas/no-prompt)) 2295 | (message "Finished Y package configurations.") 2296 | 2297 | ; Customizations 2298 | ;% Leave these alone. 2299 | (message "Start custom set-variables") 2300 | ;; Set the C_INCLUDE_PATH environment variable 2301 | (setenv "C_INCLUDE_PATH" "/opt/homebrew/include") 2302 | (custom-set-variables 2303 | ;; custom-set-variables was added by Custom. 2304 | ;; If you edit it by hand, you could mess it up, so be careful. 2305 | ;; Your init file should contain only one such instance. 2306 | ;; If there is more than one, they won't work right. 2307 | '(codeium/metadata/api_key "5519bf51-92c1-44c6-a134-08ac03cb342b") 2308 | '(copilot-network-proxy '(:host "\"127.0.0.1\"" :port 7890)) 2309 | '(copilot-node-executable "/opt/homebrew/bin/node") 2310 | '(display-battery-mode t) 2311 | '(global-display-line-numbers-mode t) 2312 | '(pdf-view-incompatible-modes 2313 | '(linum-mode linum-relative-mode helm-linum-relative-mode nlinum-mode 2314 | nlinum-hl-mode nlinum-relative-mode yalinum-mode)) 2315 | '(showkey-log-mode t) 2316 | '(weatherline-mode t)) 2317 | 2318 | (custom-set-faces 2319 | ;; custom-set-faces was added by Custom. 2320 | ;; If you edit it by hand, you could mess it up, so be careful. 2321 | ;; Your init file should contain only one such instance. 2322 | ;; If there is more than one, they won't work right. 2323 | '(org-document-title ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.6 :underline nil)))) 2324 | '(org-level-1 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.5)))) 2325 | '(org-level-2 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.3)))) 2326 | '(org-level-3 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.2)))) 2327 | '(org-level-4 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande" :height 1.1)))) 2328 | '(org-level-5 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande")))) 2329 | '(org-level-6 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande")))) 2330 | '(org-level-7 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande")))) 2331 | '(org-level-8 ((t (:inherit default :weight bold :foreground "Black" :font "Lucida Grande"))))) 2332 | --------------------------------------------------------------------------------