├── LICENSE ├── init.el └── README.org /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 | -------------------------------------------------------------------------------- /init.el: -------------------------------------------------------------------------------- 1 | ;; Source https://jonathanabennett.github.io/blog/2019/05/29/writing-academic-papers-with-org-mode by Jonathan Bennett 2 | ;; alias e29o='/Applications/Emacs29.3.app/Contents/MacOS/Emacs --init-directory ~/e29org --debug-init' 3 | 4 | 5 | (require 'package) 6 | (setq package-enable-at-startup nil) 7 | (setq package-archives '(("org" . "http://orgmode.org/elpa/") 8 | ("gnu" . "http://elpa.gnu.org/packages/") 9 | ("melpa" . "http://melpa.org/packages/"))) 10 | (package-initialize) 11 | 12 | (unless (package-installed-p 'use-package) 13 | (package-refresh-colontents) 14 | (package-install 'use-package)) 15 | (require 'use-package) 16 | (setq use-package-always-ensure t) 17 | 18 | 19 | (unless (package-installed-p 'quelpa) 20 | (with-temp-buffer 21 | (url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el") 22 | (eval-buffer) 23 | (quelpa-self-upgrade))) 24 | 25 | (message "Finished package manger configuration.") 26 | ;; Customizations 27 | 28 | ;;;# garbage collection 29 | (use-package gcmh 30 | :diminish gcmh-mode 31 | :config 32 | (setq gcmh-idle-delay 5 33 | gcmh-high-cons-threshold (* 16 1024 1024)) ; 16mb 34 | (gcmh-mode 1)) 35 | 36 | (add-hook 'emacs-startup-hook 37 | (lambda () 38 | (setq gc-cons-percentage 0.1))) ;; Default value for `gc-cons-percentage' 39 | 40 | (add-hook 'emacs-startup-hook 41 | (lambda () 42 | (message "Emacs ready in %s with %d garbage collections." 43 | (format "%.2f seconds" 44 | (float-time 45 | (time-subtract after-init-time before-init-time))) 46 | gcs-done))) 47 | 48 | (message "Finished garbage collection.") 49 | 50 | (message "Start settings section.") 51 | ;;;# save current init.el to ~/.saves 52 | ;; source https://www.reddit.com/r/emacs/comments/11ap924/the_most_important_snippet_in_my_emacs_init_file/ 53 | (setq 54 | backup-by-copying t ; don't clobber symlinks 55 | backup-directory-alist 56 | '(("." . "~/.e29orgInitSaves")) ; don't litter my fs tree 57 | delete-old-versions t 58 | kept-new-versions 6 59 | kept-old-versions 2 60 | version-control t) 61 | 62 | 63 | ;; Export from org to latex 64 | (setq org-latex-pdf-process 65 | '("latexmk -pdflatex='pdflatex -interaction nonstopmode -shell-escape' -pdf -bibtex -f %f")) 66 | 67 | 68 | 69 | 70 | ;;; Basics Configuration 71 | ;;(setq openai-key "[]") 72 | ;;(setq openai-api-key "") 73 | 74 | 75 | (setq inhibit-startup-message t) ;; hide the startup message 76 | ;; (load-theme 'material t) ;; load material theme 77 | ;; (global-linum-mode t) ;; enable line numbers globally 78 | (set-default 'truncate-lines t) ;; do not wrap 79 | (prefer-coding-system 'utf-8) ;; use UTF-8 80 | 81 | ;;load prefers the newest version of a file. 82 | ;; This applies when a filename suffix is not explicitly specified and load is trying various possible suffixes (see load-suffixes and load-file-rep-suffixes). Normally, it stops at the first file that exists unless you explicitly specify one or the other. If this option is non-nil, it checks all suffixes and uses whichever file is newest. 83 | ;; (setq load-prefer-newer t) --> causes RECURSIVE LOAD error 84 | 85 | ;;;# Zoom 86 | (set-face-attribute 'default nil :height 128) 87 | 88 | ;;;# Save History 89 | (savehist-mode +1) 90 | (setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring)) 91 | 92 | 93 | ;;;# Size of the starting Window 94 | (setq initial-frame-alist '((top . 1) 95 | (left . 450) 96 | (width . 101) 97 | (height . 90))) 98 | 99 | ;;;# Line wrap 100 | (global-visual-line-mode +1) 101 | (delete-selection-mode +1) 102 | (save-place-mode +1) 103 | 104 | 105 | ;;;# set browser to open url in new tab 106 | (custom-set-variables 107 | '(browse-url-browser-function (quote browse-url-firefox)) 108 | '(browse-url-firefox-new-window-is-tab t)) 109 | 110 | 111 | 112 | ;;;# Global keybindings 113 | 114 | (global-set-key (kbd "C-h D") 'devdocs-lookup) 115 | (message "End settings section.") 116 | 117 | 118 | (message "Begin custom elisp functions section.") 119 | ;;;# Elisp functions by me and others 120 | 121 | ;; * Elisp functions by me and others. 122 | 123 | ;;;### M-x description 124 | ;; Converts a selected list into a description list. 125 | ;; The elements of the list must begin with a dash. 126 | ;; The terms to be inserted into the square brackets 127 | ;; have to be added after running the function. 128 | (defun description (beg end) 129 | "wrap the active region in an 'itemize' environment, 130 | converting hyphens at the beginning of a line to \item" 131 | (interactive "r") 132 | (save-restriction 133 | (narrow-to-region beg end) 134 | (beginning-of-buffer) 135 | (insert "\\begin{description}\n") 136 | (while (re-search-forward "^- " nil t) 137 | (replace-match "\\\\item[ ]")) 138 | (end-of-buffer) 139 | (insert "\\end{description}\n"))) 140 | 141 | ;;;### M-x enumerate 142 | ;; Converts a selected list into an enumerated list. 143 | ;; The elements of the list must begin with a dash. 144 | (defun enumerate (beg end) 145 | "wrap the active region in an 'itemize' environment, 146 | converting hyphens at the beginning of a line to \item" 147 | (interactive "r") 148 | (save-restriction 149 | (narrow-to-region beg end) 150 | (beginning-of-buffer) 151 | (insert "\\begin{enumerate}\n") 152 | (while (re-search-forward "^- " nil t) 153 | (replace-match "\\\\item ")) 154 | (end-of-buffer) 155 | (insert "\\end{enumerate}\n"))) 156 | (message "Finishd M-x enumerate configurations. Line 4369.") 157 | 158 | ;;;### M-x itemize 159 | ;; Converts a selected list into an itemized list. 160 | ;; The elements of the list must begin with a dash. 161 | ;; A similar function could be made to make an enumerated list 162 | ;; and a description list. 163 | ;; Source: \url{https://tex.stackexchange.com/questions/118958/emacsauctex-prevent-region-filling-when-inserting-itemize} 164 | (defun itemize (beg end) 165 | "wrap the active region in an 'itemize' environment, 166 | converting hyphens at the beginning of a line to \item" 167 | (interactive "r") 168 | (save-restriction 169 | (narrow-to-region beg end) 170 | (beginning-of-buffer) 171 | (insert "\\begin{itemize}\n") 172 | (while (re-search-forward "^- " nil t) 173 | (replace-match "\\\\item ")) 174 | (end-of-buffer) 175 | (insert "\\end{itemize}\n"))) 176 | (message "Finishd defun itemize. Line 4389.") 177 | 178 | 179 | (defun ichmk () 180 | "Inserts a checkmark." 181 | (interactive) 182 | (insert "\\\item \\checkmark ")) 183 | 184 | 185 | ;;;### org headlies to beamer slides in region 186 | 187 | ;; *** M-x org-to-beamer-slides-in-region 188 | 189 | (defun org-to-beamer-slides-in-region (start end) 190 | "Convert an Org-mode outline as a list of headlines into Beamer slides flanked by unnumbered subsections and notes. The output can be pasted into a beam slideshow on Overleaf." 191 | (interactive "r") 192 | (save-restriction 193 | (narrow-to-region start end) 194 | (goto-char (point-min)) 195 | (while (re-search-forward "^\\*+ \\(.*\\)$" nil t) 196 | (let ((title (match-string 1))) 197 | (replace-match (concat "\\\\subsection*{" title "}\n\\\\begin{frame}\n\\\\frametitle{" title "}\n") nil nil) 198 | (end-of-line) 199 | (insert "\n\\end{frame}\n\\note{Your note here}\n\n")))) 200 | (message "Conversion to Beamer slides complete!")) 201 | 202 | 203 | 204 | 205 | 206 | ;;;; https://stackoverflow.com/questions/539984/how-do-i-get-emacs-to-fill-sentences-but-not-paragraphs/6103404#6103404 207 | ;;;; Unwrap paragraphs into one sentence per line. 208 | (defun fill-sentences-in-paragraph () 209 | "Put a newline at the end of each sentence in paragraph." 210 | (interactive) 211 | (save-excursion 212 | (mark-paragraph) 213 | (call-interactively 'fill-sentences-in-region))) 214 | 215 | (defun fill-sentences-in-region (start end) 216 | "Put a newline at the end of each sentence in region." 217 | (interactive "*r") 218 | (call-interactively 'unfill-region) 219 | (save-excursion 220 | (goto-char start) 221 | (while (re-search-forward "[.?!][]\"')}]*\\( \\)" end t) 222 | (newline-and-indent)))) 223 | 224 | ;;;### my-openai-api-key 225 | (defun my-openai-api-key () 226 | "Read api key from disk." 227 | (with-temp-buffer 228 | (insert-file-contents "~/openaikey.txt") 229 | (string-trim (buffer-string)))) 230 | 231 | 232 | 233 | (defun unfill-region (beg end) 234 | "Unfill the region, joining text paragraphs into a 235 | single logical line. This is useful, e.g., for use 236 | with 'visual-line-mode'." 237 | (interactive "*r") 238 | (let ((fill-column (point-max))) 239 | (fill-region beg end))) 240 | 241 | (global-set-key "\M-q" 'fill-sentences-in-paragraph) 242 | 243 | 244 | ;;;## reload-init-e29org 245 | ;; Inspried https://sachachua.com/dotemacs/index.html#org4dd39d0 246 | (defun reload-init-e29org () 247 | "Reload the init.el file for e29org. Edit the path to suite your needs." 248 | (interactive) 249 | (load-file "~/e29org/init.el")) 250 | 251 | ;;;## reload-hydras 252 | (defun reload-hydras () 253 | "Reload my-hydras.el. Edit the path to suite your needs." 254 | (interactive) 255 | (load-file "~/emacs29.3/my-hydras/my-hydras.el")) 256 | 257 | ;;;## reload-learning-spiral-hydras 258 | (defun reload-learning-spiral-hydras () 259 | "Reload learning-spiral-hydras.el. Edit the path to suite your needs." 260 | (interactive) 261 | (load-file "~/emacs29.3/my-hydras/learning-spiral-hydras.el")) 262 | 263 | ;;;## reload-writing-projects-hydra 264 | (defun reload-writing-projects-hydra () 265 | "Reload lwriting-projects-hdyra.el. Edit the path to suite your needs." 266 | (interactive) 267 | (load-file "~/emacs29.3/my-hydras/writing-projects-hydra.el")) 268 | 269 | ;;;## reload-talon-quiz-hydras 270 | ;;(defun reload-talon-quiz-hydras () 271 | ;; "Reload learning-spiral-hydras.el. Edit the path to suite your needs." 272 | ;; (interactive) 273 | ;; (load-file "~/emacs29.3/my-hydras/talon-quiz-hydras.el")) 274 | 275 | ;;;## reload-uniteai 276 | (defun reload-uniteai () 277 | "Reload my-uniteai.el. Edit the path to suite your needs." 278 | (interactive) 279 | (load-file "~/e29org/my-uniteai.el")) 280 | 281 | ;;;# Clean and sort list of items in region 282 | 283 | ;; *** clean-sort-list-in-region 284 | 285 | (defun clean-sort-list-in-region (beg end) 286 | "Clean and sort the lines in the selected region. 287 | Removes duplicate lines, blank lines, and sort alphabetically. 288 | Built by Copilot" 289 | (interactive "r") 290 | (let ((lines (split-string (buffer-substring-no-properties beg end) "\n" t)) 291 | (cleaned-lines nil)) 292 | ;; Remove duplicates and blank lines 293 | (dolist (line lines) 294 | (when (and (not (string-blank-p line)) 295 | (not (member line cleaned-lines))) 296 | (push line cleaned-lines))) 297 | ;; Sort alphabetically 298 | (setq cleaned-lines (sort cleaned-lines #'string<)) 299 | ;; Replace the region with the cleaned and sorted lines 300 | (delete-region beg end) 301 | (insert (mapconcat #'identity cleaned-lines "\n")))) 302 | (global-set-key (kbd "C-c s") 'clean-sort-list-in-region) 303 | 304 | 305 | ;; source https://emacs.stackexchange.com/questions/12938/how-can-i-evaluate-elisp-in-an-orgmode-file-when-it-is-opened 306 | ;; I use this to invoke wc-mode in manuscript documents. 307 | (defun tdh/eval-startblock () 308 | (if (member "startblock" (org-babel-src-block-names)) 309 | (save-excursion 310 | (org-babel-goto-named-src-block "startblock") 311 | (org-babel-execute-src-block)) 312 | nil 313 | ) 314 | ) 315 | (add-hook 'org-mode-hook 'tdh/eval-startblock) 316 | 317 | 318 | ;; source https://irreal.org/blog/?p=5722 319 | ;; works on regions well 320 | (defun my/count-words-in-subtree-or-region () 321 | ;; Bind this to a key in org-mode, e.g. C-= 322 | (interactive) 323 | (call-interactively (if (region-active-p) 324 | 'count-words-region 325 | 'my/count-words-in-subtree))) 326 | 327 | (defun my/count-words-in-subtree () 328 | "Count words in current node and child nodes, excluding heading text." 329 | (interactive) 330 | (org-with-wide-buffer 331 | (message "%s words in subtree" 332 | (-sum (org-map-entries 333 | (lambda () 334 | (outline-back-to-heading) 335 | (forward-line 1) 336 | (while (or (looking-at org-keyword-time-regexp) 337 | (org-in-drawer-p)) 338 | (forward-line 1)) 339 | (count-words (point) 340 | (progn 341 | (outline-end-of-subtree) 342 | (point)))) 343 | nil 'tree))))) 344 | 345 | 346 | 347 | 348 | ;;;# open PDFs with default system viewer (usually Preview on a Mac) 349 | ;; source: http://stackoverflow.com/a/1253761/1325477https://emacs.stackexchange.com/questions/3105/how-to-use-an-external-program-as-the-default-way-to-open-pdfs-from-emacs 350 | ;; Remove "\\.pdf" to enable use of PDF tools 351 | (defun mac-open (filename) 352 | (interactive "fFilename: ") 353 | (let ((process-connection-type)) 354 | (start-process "" nil "open" (expand-file-name filename)))) 355 | 356 | (defun find-file-auto (orig-fun &rest args) 357 | (let ((filename (car args))) 358 | (if (cl-find-if 359 | (lambda (regexp) (string-match regexp filename)) 360 | '( "\\.doc\\'" "\\.docx?\\'" "\\.xlsx?\\'" "\\.xlsm?\\'" "\\.pptx?\\'" "\\.itmz\\'" "\\.png\\'")) 361 | (mac-open filename) 362 | (apply orig-fun args)))) 363 | 364 | (advice-add 'find-file :around 'find-file-auto) 365 | 366 | 367 | ;; Copy template writing log, rename the file with the project ID included in the filename, and open the file in a new buffer. 368 | ;; Translated the corresponding bash function with copilot. 369 | (defun orglog (projectID) 370 | "Copy template writing log in org with project number in title and open the file." 371 | (interactive "sProject ID: ") 372 | (if (or (string= projectID "") 373 | (string-match-p " " projectID)) 374 | (progn 375 | (message "Usage: orglog projectID") 376 | (error "Invalid number of arguments")) 377 | (let ((template "~/6112MooersLabGitHubLabRepos/writingLogTemplateInOrg/writingLogTemplateVer7.org") 378 | (destination (concat "log" projectID ".org"))) 379 | (copy-file template destination t) 380 | (find-file destination) 381 | (message "Write writing log to %s file and open in a new buffer." destination)))) 382 | 383 | 384 | ;; *** wrap-region-with-org-src-block 385 | 386 | ;; Wrap a marked block of elisp code with a org-mode source block. 387 | ;; I need to make a varient for LaTeX minted code environment. 388 | 389 | (defun wrap-region-with-org-src-block () 390 | "Wrap the selected region with an elisp source block." 391 | (interactive) 392 | (let ((begin (region-beginning)) 393 | (end (region-end))) 394 | (goto-char end) 395 | (insert "\n#+END_SRC") 396 | (goto-char begin) 397 | (insert "#+BEGIN_SRC emacs-lisp\n"))) 398 | 399 | (global-set-key (kbd "C-c w") 'wrap-region-with-org-src-block) 400 | 401 | 402 | 403 | 404 | ; ** create-latex-table-with-caption 405 | ; 406 | ; This interactive function prompts the user for the number of rows, columns, caption, and label. 407 | ; Then this function generates a table that has a top Rule and a rule below the column labels. 408 | ; It also has a bottom rule. It does not contain any vertical rules. 409 | ; This function required five rounds of iteration with Copilot. 410 | ; It was developed after developing the function below: create-org-table-with-caption. 411 | ; That code was used as a template for Copilot. 412 | ; It in turn had been developed after four or five rounds of iteration. 413 | 414 | (defun create-latex-table-with-caption () 415 | (interactive) 416 | (let ((rows (read-number "Enter the number of rows: ")) 417 | (cols (read-number "Enter the number of columns: ")) 418 | (caption (read-string "Enter the table's caption: ")) 419 | (label (read-string "Enter the table's label: "))) 420 | (insert (format "\\begin{table}[h]\n\\centering\n\\caption{%s \\label{%s}}\n\\begin{tabular}{%s}\n\\hline\n" 421 | caption label (make-string cols ?c))) 422 | ;; Insert column labels 423 | (dotimes (col cols) 424 | (insert (format " %c " (+ ?A col))) 425 | (if (< col (1- cols)) 426 | (insert "&"))) 427 | (insert " \\\\\n\\hline\n") 428 | ;; Insert table rows 429 | (dotimes (_ rows) 430 | (dotimes (col cols) 431 | (insert (format " Cell %d-%d " (1+ col) (1+ _))) 432 | (if (< col (1- cols)) 433 | (insert "&"))) 434 | (insert " \\\\\n")) 435 | (insert "\\hline\n\\end{tabular}\n\\end{table}\n"))) 436 | 437 | 438 | 439 | 440 | 441 | ;** create-org-table-with-caption 442 | ;This interactive function prompts the user for the number of rows. columns, and the caption of the table. 443 | 444 | (defun create-org-table-with-caption () 445 | "This interactive function prompts the user for the number of rows. columns, and the caption of the table." 446 | (interactive) 447 | (let ((rows (read-number "Enter the number of rows: ")) 448 | (cols (read-number "Enter the number of columns: ")) 449 | (label (read-string "Enter the table label: ")) 450 | (caption (read-string "Enter the table's caption: "))) 451 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 452 | (insert (format "#+NAME: %s\n" label)) 453 | (insert "|") 454 | (dotimes (_ cols) 455 | (insert "----+")) 456 | (insert "\n|") 457 | ;;(insert "|") 458 | (dotimes (col cols) 459 | (insert (format " %c |" (+ ?A col)))) 460 | (insert "\n|") 461 | (dotimes (_ cols) 462 | (insert "----+")) 463 | (insert "\n") 464 | (dotimes (_ rows) 465 | (insert "|") 466 | (dotimes (_ cols) 467 | (insert " |")) 468 | (insert "\n")) 469 | (insert "|") 470 | (dotimes (_ cols) 471 | (insert "----+")))) 472 | 473 | ; *** insert-org-captioned-figure 474 | ; 475 | ; The function prompts the user for the image file path and name, the label, and the caption. 476 | 477 | (defun insert-org-captioned-figure () 478 | "Insert a captioned figure in Org-mode." 479 | (interactive) 480 | (let ((image-name (read-string "Enter the image file path: ")) 481 | (label (read-string "Enter the figure label: ")) 482 | (caption (read-string "Enter the figure caption: "))) 483 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 484 | (insert (format "#+NAME: %s\n" label)) 485 | (insert (format "[[file:%s]]\n" image-name)))) 486 | 487 | 488 | ;; *** latex-to-org-list-region 489 | 490 | ;; Select a list of items in LaTex and convert to list of items in org-mode 491 | 492 | ;; To use this function, select the region containing the LaTeX list and run: 493 | ;; M-x latex-to-org-list-region 494 | 495 | (defun latex-to-org-list-region (start end) 496 | "Convert a LaTeX itemize list in the region to an Org-mode list." 497 | (interactive "r") 498 | (save-excursion 499 | (goto-char start) 500 | (while (re-search-forward "\\\\item" end t) 501 | (replace-match "-")))) 502 | 503 | 504 | 505 | 506 | (message "End of the custom elisp functions section.") 507 | 508 | 509 | 510 | ;;# Shell configuration 511 | (use-package exec-path-from-shell 512 | :init 513 | (setenv "SHELL" "/opt/local/bin/bash") 514 | :if (memq window-system '(mac ns x)) 515 | :config 516 | (setq exec-path-from-shell-variables '("PATH" "GOPATH" "PYTHONPATH")) 517 | (exec-path-from-shell-initialize)) 518 | (message "Finished shell configuration. Line 480.") 519 | 520 | 521 | ;;;# Size of the starting Window 522 | (setq initial-frame-alist '((top . 1) 523 | (left . 450) 524 | (width . 101) 525 | (height . 90))) 526 | 527 | 528 | 529 | ;;;# Faked full screen 530 | (use-package maxframe) 531 | (defvar my-fullscreen-p t "Check if fullscreen is on or off") 532 | (defun my-toggle-fullscreen () 533 | (interactive) 534 | (setq my-fullscreen-p (not my-fullscreen-p)) 535 | (if my-fullscreen-p 536 | (restore-frame) 537 | (maximize-frame))) 538 | (global-set-key (kbd "M-S") 'toggle-frame-fullscreen) ;; conflicts with an auctex command to insert an \item in a list. 539 | (message "Finished frame configuration. Line 493.") 540 | 541 | ;;;# Backups 542 | (setq vc-make-backup-files t) 543 | 544 | (setq version-control t ;; Use version numbers for backups. 545 | kept-new-versions 10 ;; Number of newest versions to keep. 546 | kept-old-versions 0 ;; Number of oldest versions to keep. 547 | delete-old-versions t ;; Don't ask to delete excess backup versions. 548 | backup-by-copying t) ;; Copy all files, don't rename them. 549 | 550 | ;; If you want to avoid 'backup-by-copying', you can instead use 551 | ;; 552 | ;; (setq backup-by-copying-when-linked t) 553 | ;; 554 | ;; but that makes the second, "per save" backup below not run, since 555 | ;; buffers with no backing file on disk are not backed up, and 556 | ;; renaming removes the backing file. The "per session" backup will 557 | ;; happen in any case, you'll just have less consistent numbering of 558 | ;; per-save backups (i.e. only the second and subsequent save will 559 | ;; result in per-save backups). 560 | 561 | ;; If you want to avoid backing up some files, e.g. large files, 562 | ;; then try setting 'backup-enable-predicate'. You'll want to 563 | ;; extend 'normal-backup-enable-predicate', which already avoids 564 | ;; things like backing up files in '/tmp'. 565 | ;;;# Default and per-save backups go here: 566 | (setq backup-directory-alist '(("" . "~/e29org/backup/per-save"))) 567 | 568 | (defun force-backup-of-buffer () 569 | ;; Make a special "per session" backup at the first save of each 570 | ;; emacs session. 571 | (when (not buffer-backed-up) 572 | ;; Override the default parameters for per-session backups. 573 | (let ((backup-directory-alist '(("" . "~/e29org/backup/per-session"))) 574 | (kept-new-versions 3)) 575 | (backup-buffer))) 576 | ;; Make a "per save" backup on each save. The first save results in 577 | ;; both a per-session and a per-save backup, to keep the numbering 578 | ;; of per-save backups consistent. 579 | (let ((buffer-backed-up nil)) 580 | (backup-buffer))) 581 | (add-hook 'before-save-hook 'force-backup-of-buffer) 582 | (message "Finished force-backup-of-buffer configuration. Line 537.") 583 | 584 | ;;;# Do not move the current file while creating backup. 585 | (setq backup-by-copying t) 586 | (message "Backup configuration finished. Line 541.") 587 | 588 | ;;;# Disable lockfiles. 589 | (setq create-lockfiles nil) 590 | 591 | (message "Finished lockfile configuration. Line 235.") 592 | 593 | (column-number-mode) 594 | 595 | ;;;# Show stray whitespace. 596 | (setq-default show-trailing-whitespace t) 597 | (setq-default indicate-empty-lines t) 598 | (setq-default indicate-buffer-boundaries 'left) 599 | 600 | ;;;# Add a newline automatically at the end of a file while saving. 601 | (setq-default require-final-newline t) 602 | 603 | ;;;# A single space follows the end of sentence. 604 | (setq sentence-end-double-space nil) 605 | 606 | 607 | 608 | 609 | (message "Finished find file configuration. Line 584.") 610 | 611 | ;; (global-set-key (kbd "C-c p") 'dpkg-menpdf 612 | 613 | 614 | ;;;# Turn on font-locking or syntax highlighting 615 | (global-font-lock-mode t) 616 | 617 | ;;;# font size in the modeline 618 | (set-face-attribute 'mode-line nil :height 140) 619 | 620 | ;;;# set default coding of buffers 621 | (setq default-buffer-file-coding-system 'utf-8-unix) 622 | 623 | ;; Switch from tabs to spaces for indentation 624 | ;; Set the indentation level to 4. 625 | (setq-default indent-tabs-mode nil) 626 | (setq-default tab-width 4) 627 | 628 | ;;;# Indentation setting for various languages. 629 | (setq c-basic-offset 4) 630 | (setq js-indent-level 2) 631 | (setq css-indent-offset 2) 632 | (setq python-basic-offset 4) 633 | 634 | (setq user-init-file "/Users/blaine/e29org/init.el") 635 | (setq user-emacs-directory "/Users/blaine/e29org/") 636 | ;; (setq default-directory "/Users/blaine") 637 | ;; the directory that you start Emacs in should be the default for the current buffer 638 | (setenv "HOME" "/Users/blaine") 639 | ;; (load user-init-file) 640 | 641 | 642 | (advice-add 'describe-function-1 :after #'elisp-demos-advice-describe-function-1) 643 | 644 | (advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update) 645 | 646 | ;;;# Write customizations to a separate file instead of this file. 647 | (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) 648 | (load custom-file t) 649 | 650 | 651 | 652 | 653 | ;;;# Custom command. 654 | (defun show-current-time () 655 | "Show current time." 656 | (interactive) 657 | (message (current-time-string))) 658 | 659 | ;;;# Custom key sequences. 660 | ;; (global-set-key (kbd "C-c t") 'show-current-time) 661 | (global-set-key (kbd "C-c d") 'delete-trailing-whitespace) 662 | 663 | 664 | ;;;# display line numbers. Need with s-l. 665 | (global-display-line-numbers-mode) 666 | 667 | ;;;# hippie-expand M-/. Seems to be comflicting with Corfu, Cape, and dabrrev. 668 | ;; (global-set-key [remap dabbrev-expand] 'hippie-expand) 669 | 670 | 671 | ;;;# GUI related settings 672 | (if (display-graphic-p) 673 | (progn 674 | ;; Removed some UI elements 675 | ;; (menu-bar-mode -1) 676 | (tool-bar-mode -1) 677 | (scroll-bar-mode -1) 678 | ;; Show battery status 679 | (display-battery-mode 1))) 680 | 681 | 682 | ;; Hey, stop being a whimp and learn the Emacs keybindings! 683 | ;; ;; Set copy+paste 684 | ;; (cua-mode t) 685 | ;; (setq cua-auto-tabify-rectangles nil) ;; Don't tabify after rectangle commands 686 | ;; (transient-mark-mode 1) ;; No region when it is not highlighted 687 | ;; (setq cua-keep-region-after-copy t) ;; Standard Windows behaviour 688 | 689 | ;; REMOVE THE SCRATCH BUFFER AT STARTUP 690 | ;; Makes *scratch* empty. 691 | ;; (setq initial-scratch-message "") 692 | ;; Removes *scratch* from buffer after the mode has been set. 693 | ;; (defun remove-scratch-buffer () 694 | ;; (if (get-buffer "*scratch*") 695 | ;; (kill-buffer "*scratch*"))) 696 | ;; (add-hook 'after-change-major-mode-hook 'remove-scratch-buffer) 697 | 698 | 699 | ;;;# Disable the C-z sleep/suspend key 700 | ;; See http://stackoverflow.com/questions/28202546/hitting-ctrl-z-in-emacs-freezes-everything 701 | (global-unset-key (kbd "C-z")) 702 | 703 | ;; Disable the C-x C-b key, use helm (C-x b) instead 704 | ;; (global-unset-key (kbd "C-x C-b")) 705 | 706 | 707 | ;;;# Make copy and paste use the same clipboard as emacs. 708 | (setq select-enable-primary t 709 | select-enable-clipboard t) 710 | 711 | 712 | (setq display-time-default-load-average nil) 713 | (setq display-time-day-and-date t display-time-24hr-format t) 714 | (display-time-mode t) 715 | 716 | 717 | ;;;# dired-icon-mode 718 | (use-package dired-icon 719 | :ensure t 720 | :config 721 | (add-hook 'dired-mode-hook 'dired-icon-mode)) 722 | 723 | 724 | ;; Revert Dired and other buffers after changes to files in directories on disk. 725 | ;; Source: [[https://www.youtube.com/watch?v=51eSeqcaikM&list=PLEoMzSkcN8oNmd98m_6FoaJseUsa6QGm2&index=2][Dave Wilson]] 726 | (setq global-auto-revert-non-file-buffers t) 727 | 728 | 729 | ;;;# customize powerline 730 | ;; (line above the command line at the bottom of the screen) 731 | (use-package powerline) 732 | (powerline-default-theme) 733 | 734 | 735 | ;;;# Add line numbers. 736 | ;; (global-nlinum-mode t) 737 | 738 | ;;;# highlight current line 739 | (global-hl-line-mode +1) 740 | (set-face-background hl-line-face "wheat1") 741 | (set-face-attribute 'mode-line nil :height 180) 742 | 743 | ;;;# List recently opened files. 744 | ;; Recent files 745 | (recentf-mode 1) 746 | (global-set-key "\C-x\ \C-r" 'recentf-open-files) 747 | 748 | ;;;# UTF-8 749 | (set-language-environment "UTF-8") 750 | (set-default-coding-systems 'utf-8) 751 | (set-keyboard-coding-system 'utf-8-unix) 752 | (set-terminal-coding-system 'utf-8-unix) 753 | 754 | 755 | 756 | ;;;# Quickly access dot emacs d 757 | (global-set-key (kbd "C-c e") 758 | (lambda() 759 | (interactive) 760 | (find-file "~/e29org/init.el"))) 761 | 762 | 763 | (set-face-attribute 'default nil :height 140) 764 | 765 | (set-frame-parameter (selected-frame) 'buffer-predicate 766 | (lambda (buf) 767 | (let ((name (buffer-name buf))) 768 | (not (or (string-prefix-p "*" name) 769 | (eq 'dired-mode (buffer-local-value 'major-mode buf))))))) 770 | 771 | 772 | ;;;# Global keys 773 | ;; If you use a window manager be careful of possible key binding clashes 774 | (setq recenter-positions '(top middle bottom)) 775 | (global-set-key (kbd "C-1") 'kill-this-buffer) 776 | (global-set-key (kbd "C-") (kbd "C-u 1 C-v")) 777 | (global-set-key (kbd "C-") (kbd "C-u 1 M-v")) 778 | (global-set-key [C-tab] 'other-window) 779 | (global-set-key (kbd "C-c c") 'calendar) 780 | (global-set-key (kbd "C-x C-b") 'ibuffer) 781 | (global-set-key (kbd "C-`") 'mode-line-other-buffer) 782 | ;; (global-set-key (kbd "M-/") #'hippie-expand) 783 | (global-set-key (kbd "C-x C-j") 'dired-jump) 784 | (global-set-key (kbd "C-c r") 'remember) 785 | 786 | 787 | (setq case-fold-search t) 788 | 789 | 790 | ;; Show the file path in the title of the frame 791 | ;; source https://stackoverflow.com/questions/2903426/display-path-of-file-in-status-bar See entry by mortnene 792 | ;; This is much more useful than just showing the file name or buffer name in the frame title. 793 | 794 | (setq frame-title-format 795 | '(:eval 796 | (if buffer-file-name 797 | (replace-regexp-in-string 798 | "\\\\" "/" 799 | (replace-regexp-in-string 800 | (regexp-quote (getenv "HOME")) "e30: ~" 801 | (convert-standard-filename buffer-file-name))) 802 | (buffer-name)))) 803 | 804 | 805 | ; ;; Source https://stackoverflow.com/questions/50222656/setting-emacs-frame-title-in-emacs 806 | ; (setq frame-title-format 807 | ; (concat "%b - emacs@" (system-name))) 808 | ; (setq-default frame-title-format '("%f [%m]")) 809 | ; (setq frame-title-format "Main emacs29.3 config - %b " ) 810 | 811 | 812 | 813 | 814 | ;;;# Browse URLS in text mode 815 | (global-goto-address-mode +1) 816 | 817 | 818 | ;;;# Revert buffers when the underlying file has changed. 819 | (global-auto-revert-mode 1) 820 | 821 | 822 | ;;;# Save history going back 25 commands. 823 | ;; Use M-p to get previous command used in the minibuffer. 824 | ;; Use M-n to move to next command. 825 | (setq history-length 25) 826 | (savehist-mode 1) 827 | 828 | 829 | ;;;# Save place in a file. 830 | (save-place-mode 1) 831 | 832 | 833 | ;;;# sets monday to be the first day of the week in calendar 834 | (setq calendar-week-start-day 1) 835 | 836 | ;;;# save emacs backups in a different directory 837 | ;; (some build-systems build automatically all files with a prefix, and .#something.someending breakes that) 838 | (setq backup-directory-alist '(("." . "~/.emacsbackups"))) 839 | 840 | 841 | ;;;# Enable show-paren-mode (to visualize paranthesis) and make it possible to delete things we have marked 842 | (show-paren-mode 1) 843 | (delete-selection-mode 1) 844 | 845 | 846 | ;;;# use y or n instead of yes or no 847 | (defalias 'yes-or-no-p 'y-or-n-p) 848 | 849 | ;;;# These settings enables using the same configuration file on multiple platforms. 850 | ;; Note that windows-nt includes [[https://www.gnu.org/software/emacs/manual/html_node/elisp/System-Environment.html][windows 10]]. 851 | (defconst *is-a-mac* (eq system-type 'darwin)) 852 | (defconst *is-a-linux* (eq system-type 'gnu/linux)) 853 | (defconst *is-windows* (eq system-type 'windows-nt)) 854 | (defconst *is-cygwin* (eq system-type 'cygwin)) 855 | (defconst *is-unix* (not *is-windows*)) 856 | 857 | 858 | ;; ==> adjust here 859 | ;; See this [[http://ergoemacs.org/emacs/emacs_hyper_super_keys.html][ for more information.]] 860 | ;; set keys for Apple keyboard, for emacs in OS X 861 | ;; Source http://xahlee.info/emacs/emacs/emacs_hyper_super_keys.html 862 | (setq mac-command-modifier 'meta) ; make cmd key do Meta 863 | (setq mac-option-modifier 'super) ; make option key do Super. 864 | (setq mac-control-modifier 'control) ; make Control key do Control 865 | (setq mac-function-modifier 'hyper) ; make Fn key do Hyper. Only works on Apple produced keyboards. 866 | (setq mac-right-command-modifier 'hyper) 867 | 868 | 869 | 870 | ;;;# Copy selected region to kill ring and clipboard. Should use M-w for same functionality. 871 | (define-key global-map (kbd "H-c") 'cua-copy-region) 872 | 873 | 874 | ;;;# Save the buffer. Should use C-x 0 875 | ;; (define-key global-map (kbd "s-s") 'save-buffer) 876 | 877 | 878 | ;;;# Switch to previous buffer 879 | (define-key global-map (kbd "H-") 'previous-buffer) 880 | ;;;# Switch to next buffer 881 | (define-key global-map (kbd "H-") 'next-buffer) 882 | 883 | 884 | ;;;# Minibuffer history keybindings 885 | ;; The calling up of a previously issued command in the minibuffer with ~M-p~ saves times. 886 | (autoload 'edit-server-maybe-dehtmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 887 | (autoload 'edit-server-maybe-htmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 888 | (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer) 889 | (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer) 890 | (define-key minibuffer-local-map (kbd "M-p") 'previous-complete-history-element) 891 | (define-key minibuffer-local-map (kbd "M-n") 'next-complete-history-element) 892 | (define-key minibuffer-local-map (kbd "") 'previous-complete-history-element) 893 | (define-key minibuffer-local-map (kbd "") 'next-complete-history-element) 894 | 895 | ;;;# switch-to-minibuffer 896 | (defun switch-to-minibuffer () 897 | "Switch to minibuffer window." 898 | (interactive) 899 | (if (active-minibuffer-window) 900 | (select-window (active-minibuffer-window)) 901 | (error "Minibuffer is not active"))) 902 | 903 | (global-set-key "\C-cm" 'switch-to-minibuffer) ;; Bind to `C-c m' for minibuffer. 904 | 905 | ;;;# Bibtex configuration 906 | (defconst blaine/bib-libraries (list "/Users/blaine/Documents/global.bib")) 907 | 908 | ;;;# Combined with emacs-mac, this gives good PDF quality for [[https://www.aidanscannell.com/post/setting-up-an-emacs-playground-on-mac/][retina display]]. 909 | (setq pdf-view-use-scaling t) 910 | 911 | 912 | ;;;# PDF default page width behavior 913 | (setq-default pdf-view-display-size 'fit-page) 914 | 915 | 916 | ;;;# Set delay in the matching parenthesis to zero. 917 | (setq show-paren-delay 0) 918 | (show-paren-mode t) 919 | 920 | ;;;# Window management 921 | ;; winner-mode C-c undo change C-c redo change 922 | (winner-mode 1) 923 | 924 | (defun split-vertical-evenly () 925 | (interactive) 926 | (command-execute 'split-window-vertically) 927 | (command-execute 'balance-windows)) 928 | (global-set-key (kbd "C-x 2") 'split-vertical-evenly) 929 | 930 | 931 | (defun split-horizontal-evenly () 932 | (interactive) 933 | (command-execute 'split-window-horizontally) 934 | (command-execute 'balance-windows)) 935 | (global-set-key (kbd "C-x 3") 'split-horizontal-evenly) 936 | 937 | (message "Starting config of packages--takes 5-60 seconds, depending on the operating system.") 938 | 939 | ;;;# Zoom in and out via C-scroll wheel 940 | ;; (global-set-key [C-wheel-up] 'text-scale-increase) 941 | ;; (global-set-key [C-wheel-down] 'text-scale-decrease) 942 | 943 | ;;;# Control-scroll wheel to zoom in and out. Very Sweet! 944 | (global-set-key [C-mouse-4] 'text-scale-increase) 945 | (global-set-key [C-mouse-5] 'text-scale-decrease) 946 | 947 | 948 | ;;; Aliases 949 | ;; Source: https://www.youtube.com/watch?v=ufVldIrUOBg 950 | ;; Defalias: a quick guide to making an alias in Emacs 951 | ;; Usage: M-x ct 952 | 953 | (defalias 'ct 'customize-themes) 954 | (defalias 'cz 'customize) 955 | (defalias 'ddl 'delete-duplicate-lines) 956 | (defalias 'dga 'define-global-abbrev) 957 | (defalias 'dma 'define-mode-abbrev) 958 | (defalias 'ea 'edit-abbrevs) 959 | (defalias 'ff 'flip-frame) 960 | (defalias 'fl 'flush-lines) 961 | (defalias 'fnd 'find-name-dired) 962 | (defalias 'klm 'kill-matching-lines) 963 | (defalias 'lc 'langtool-check) 964 | (defalias 'lcu 'langtool-check-buffer) 965 | (defalias 'lp 'list-packages) 966 | (defalias 'pcr 'package-refresh-contents) 967 | (defalias 'pi 'package-install) 968 | (defalias 'pua 'package-upgrade-all) 969 | (defalias 'qr 'query-replace) 970 | (defalias 'rg 'rgrep) 971 | (defalias 'rsv 'replace-smart-quotes) 972 | (defalias 'sl 'sort-lines) 973 | (defalias 'slo 'single-lines-only) 974 | (defalias 'spe 'ispell-region) 975 | (defalias 'udd 'package-upgrade-all) 976 | (defalias 'ugg 'package-upgrade-all) 977 | (defalias 'wr 'write-region) 978 | (message "Finished global settings section.") 979 | 980 | 981 | (message "Start package configurations A") 982 | 983 | ;;** ace-window 984 | (global-set-key (kbd "M-o") 'ace-window) 985 | ;; the list of initial characters used in window labels: 986 | (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) 987 | ;; default settings 988 | (defvar aw-dispatch-alist 989 | '((?x aw-delete-window "Delete Window") 990 | (?m aw-swap-window "Swap Windows") 991 | (?M aw-move-window "Move Window") 992 | (?c aw-copy-window "Copy Window") 993 | (?j aw-switch-buffer-in-window "Select Buffer") 994 | (?n aw-flip-window) 995 | (?u aw-switch-buffer-other-window "Switch Buffer Other Window") 996 | (?c aw-split-window-fair "Split Fair Window") 997 | (?v aw-split-window-vert "Split Vert Window") 998 | (?b aw-split-window-horz "Split Horz Window") 999 | (?o delete-other-windows "Delete Other Windows") 1000 | (?? aw-show-dispatch-help)) 1001 | "List of actions for `aw-dispatch-default'.") 1002 | 1003 | 1004 | 1005 | (use-package auctex 1006 | :ensure t 1007 | :defer t 1008 | :hook (LaTeX-mode . (lambda () 1009 | (push (list 'output-pdf "Skim") 1010 | TeX-view-program-selection)))) 1011 | 1012 | (message "Start package configurations C") 1013 | ;;;# C 1014 | 1015 | 1016 | (use-package citar 1017 | :bind (("C-c b" . citar-insert-citation) 1018 | :map minibuffer-local-map 1019 | ("M-b" . citar-insert-preset)) 1020 | :custom 1021 | (citar-bibliography '("/Users/blaine/Documents/global.bib")) 1022 | (citar-library-paths '("/Users/blaine/0papersLabeled") '("/Users/blaine/0booksUnlabeled")) 1023 | (citar-library-file-extensions '("pdf" "epub")) 1024 | :hook 1025 | ;; enable autocompletion in buffer of citekeys 1026 | (LaTeX-mode . citar-capf-setup) 1027 | (org-mode . citar-capf-setup)) 1028 | 1029 | (setenv "PATH" (concat "/usr/local/bin/:/opt/local/bin/" (getenv "PATH"))) 1030 | (add-to-list 'exec-path "/usr/local/bin:/opt/local/bin/") 1031 | 1032 | ;;*** citar-org, use after org-cite. It is not loaded. 1033 | ; (use-package citar-org 1034 | ; :after oc 1035 | ; :custom 1036 | ; (org-cite-insert-processor 'citar) 1037 | ; (org-cite-follow-processor 'citar) 1038 | ; (org-cite-activate-processor 'citar) 1039 | ; :general 1040 | ; (:keymaps 'org-mode-map 1041 | ; :prefix "C-c b" 1042 | ; "b" '(citar-insert-citation :wk "Insert citation") 1043 | ; "r" '(citar-insert-reference :wk "Insert reference") 1044 | ; "o" '(citar-open-notes :wk "Open note")) 1045 | ; :custom 1046 | ; (citar-notes-paths '("/Users/blaine/org-roam/citar-org-roam")) ; List of directories for reference nodes 1047 | ; (citar-open-note-function 'orb-citar-edit-note) ; Open notes in `org-roam' 1048 | ; (citar-at-point-function 'embark-act) ; Use `embark' 1049 | ; ) 1050 | 1051 | 1052 | (use-package citar-embark 1053 | ;; get a table of options including opening related files and the entry in global.bib. 1054 | :after citar embark 1055 | :no-require 1056 | :config (citar-embark-mode)) 1057 | 1058 | (use-package citar-org-roam 1059 | :after (citar org-roam) 1060 | :no-require 1061 | :config (citar-org-roam-mode)) 1062 | 1063 | (message "Finished citar package configuration.") 1064 | 1065 | 1066 | (use-package codeium 1067 | :load-path "/Users/blaine/e29org/manual-install/codeium.el/" 1068 | :init 1069 | ;; use globally 1070 | (add-to-list 'completion-at-point-functions #'codeium-completion-at-point) 1071 | ;; or on a hook 1072 | ;; (add-hook 'python-mode-hook 1073 | ;; (lambda () 1074 | ;; (setq-local completion-at-point-functions '(codeium-completion-at-point)))) 1075 | 1076 | ;; if you want multiple completion backends, use cape (https://github.com/minad/cape): 1077 | ;; (add-hook 'python-mode-hook 1078 | ;; (lambda () 1079 | ;; (setq-local completion-at-point-functions 1080 | ;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point))))) 1081 | ;; an async company-backend is coming soon! 1082 | 1083 | ;; codeium-completion-at-point is autoloaded, but you can 1084 | ;; optionally set a timer, which might speed up things as the 1085 | ;; codeium local language server takes ~0.2s to start up 1086 | ;; (add-hook 'emacs-startup-hook 1087 | ;; (lambda () (run-with-timer 0.1 nil #'codeium-init))) 1088 | 1089 | ;; :defer t ;; lazy loading, if you want 1090 | 1091 | :config 1092 | (setq use-dialog-box nil) ;; do not use popup boxes 1093 | 1094 | ;; if you don't want to use customize to save the api-key 1095 | ;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") 1096 | 1097 | ;; get codeium status in the modeline 1098 | (setq codeium-mode-line-enable 1099 | (lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion))))) 1100 | (add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t) 1101 | ;; alternatively for a more extensive mode-line 1102 | ;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t) 1103 | 1104 | ;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server 1105 | (setq codeium-api-enabled 1106 | (lambda (api) 1107 | (memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion)))) 1108 | ;; you can also set a config for a single buffer like this: 1109 | ;; (add-hook 'python-mode-hook 1110 | ;; (lambda () 1111 | ;; (setq-local codeium/editor_options/tab_size 4))) 1112 | 1113 | ;; You can overwrite all the codeium configs! 1114 | ;; for example, we recommend limiting the string sent to codeium for better performance 1115 | (defun my-codeium/document/text () 1116 | (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max)))) 1117 | ;; if you change the text, you should also change the cursor_offset 1118 | ;; warning: this is measured by UTF-8 encoded bytes 1119 | (defun my-codeium/document/cursor_offset () 1120 | (codeium-utf8-byte-length 1121 | (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point)))) 1122 | (setq codeium/document/text 'my-codeium/document/text) 1123 | (setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset) 1124 | ) 1125 | (message "Finished codeium package configuration") 1126 | 1127 | 1128 | 1129 | (message "Started corfu package configuration") 1130 | ;;;## Corfu configuration 1131 | (use-package corfu 1132 | :ensure t 1133 | :init 1134 | (setq tab-always-indent 'complete) 1135 | (global-corfu-mode) 1136 | :config 1137 | (setq corfu-auto t 1138 | corfu-echo-documentation t 1139 | corfu-scroll-margin 0 1140 | corfu-count 8 1141 | corfu-max-width 50 1142 | corfu-min-width corfu-max-width 1143 | corfu-auto-prefix 2) 1144 | 1145 | (corfu-history-mode 1) 1146 | (savehist-mode 1) 1147 | (add-to-list 'savehist-additional-variables 'corfu-history) 1148 | 1149 | (defun corfu-enable-always-in-minibuffer () 1150 | (setq-local corfu-auto nil) 1151 | (corfu-mode 1)) 1152 | (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1) 1153 | ) 1154 | (message "Finished corfu package configuration") 1155 | 1156 | ;;;## Cape Configuration 1157 | (use-package cape 1158 | :ensure t 1159 | :init 1160 | (add-to-list 'completion-at-point-functions #'cape-file) 1161 | (add-to-list 'completion-at-point-functions #'cape-keyword) 1162 | ;; kinda confusing re length, WIP/TODO 1163 | ;; :hook (org-mode . (lambda () (add-to-list 'completion-at-point-functions #'cape-dabbrev))) 1164 | ;; :config 1165 | ;; (setq dabbrev-check-other-buffers nil 1166 | ;; dabbrev-check-all-buffers nil 1167 | ;; cape-dabbrev-min-length 6) 1168 | ) 1169 | 1170 | 1171 | (use-package company-box 1172 | :ensure t 1173 | :config 1174 | (setq company-box-max-candidates 50 1175 | company-frontends '(company-tng-frontend company-box-frontend) 1176 | company-box-icons-alist 'company-box-icons-all-the-icons)) 1177 | 1178 | (with-eval-after-load 'company 1179 | (define-key company-active-map 1180 | (kbd "TAB") 1181 | #'company-complete-common-or-cycle) 1182 | (define-key company-active-map 1183 | (kbd "") 1184 | (lambda () 1185 | (interactive) 1186 | (company-complete-common-or-cycle -1)))) 1187 | 1188 | (with-eval-after-load 'company 1189 | (define-key company-active-map (kbd "M-.") #'company-show-location) 1190 | (define-key company-active-map (kbd "RET") nil)) 1191 | 1192 | 1193 | ;;;## Company Configuration 1194 | ;; Source: https://github.com/Exafunction/codeium.el 1195 | (use-package company 1196 | :ensure t 1197 | :defer 0.1 1198 | :hook ((emacs-lisp-mode . (lambda () 1199 | (setq-local company-backends '(company-elisp)))) 1200 | (emacs-lisp-mode . company-mode)) 1201 | 1202 | :config 1203 | (global-company-mode t) 1204 | (company-tng-configure-default) ; restore old tab behavior 1205 | (setq-default 1206 | company-idle-delay 0.05 1207 | company-require-match nil 1208 | company-minimum-prefix-length 1 1209 | ;; get only preview 1210 | ;; company-frontends '(company-preview-frontend) 1211 | ;; also get a drop down 1212 | company-frontends '(company-pseudo-tooltip-frontend company-preview-frontend) 1213 | )) 1214 | 1215 | 1216 | ;;;;;; Extra Completion Functions 1217 | (use-package consult 1218 | :ensure t 1219 | :after vertico 1220 | :bind (("C-x b" . consult-buffer) 1221 | ("C-x C-k C-k" . consult-kmacro) 1222 | ("C-x C-o" . consult-outline) 1223 | ("M-y" . consult-yank-pop) 1224 | ("M-g g" . consult-goto-line) 1225 | ("M-g M-g" . consult-goto-line) 1226 | ("M-g f" . consult-flymake) 1227 | ("M-g i" . consult-imenu) 1228 | ("M-s l" . consult-line) 1229 | ("M-s L" . consult-line-multi) 1230 | ("M-s u" . consult-focus-lines) 1231 | ("M-s g" . consult-ripgrep) 1232 | ("M-s M-g" . consult-ripgrep) 1233 | ("C-x C-SPC" . consult-global-mark) 1234 | ("C-x M-:" . consult-complex-command) 1235 | ; ("C-c n" . consult-org-agenda) 1236 | ("C-c m" . my/notegrep) 1237 | :map help-map 1238 | ("a" . consult-apropos) 1239 | :map minibuffer-local-map 1240 | ("M-r" . consult-history)) 1241 | :custom 1242 | (completion-in-region-function #'consult-completion-in-region) 1243 | :config 1244 | (defun my/notegrep () 1245 | "Use interactive grepping to search my notes" 1246 | (interactive) 1247 | (consult-ripgrep org-directory)) 1248 | (recentf-mode t)) 1249 | (use-package consult-dir 1250 | :ensure t 1251 | :bind (("C-x C-j" . consult-dir) 1252 | ;; :map minibuffer-local-completion-map 1253 | :map vertico-map 1254 | ("C-x C-j" . consult-dir))) 1255 | 1256 | (use-package consult-recoll 1257 | :bind (("M-s r" . counsel-recoll) 1258 | ("C-c I" . recoll-index)) 1259 | :init 1260 | (setq consult-recoll-inline-snippets t) 1261 | :config 1262 | (defun recoll-index (&optional arg) (interactive) 1263 | (start-process-shell-command "recollindex" 1264 | "*recoll-index-process*" 1265 | "recollindex"))) 1266 | (message "Finished package configurations C") 1267 | 1268 | 1269 | (message "Start package configurations D") 1270 | 1271 | ;;;# D 1272 | ;; dashboard 1273 | (use-package dashboard 1274 | :ensure t 1275 | :config 1276 | (dashboard-setup-startup-hook)) 1277 | (setq dashboard-center-content t) 1278 | (setq dashboard--ascii-banner-centered t) 1279 | (setq dashboard-banner-logo-title "Loxo or selpercatinib. FDA-approved RET kinase inhibitor to treat non-small cell lung cancer in 2020.") 1280 | (use-package all-the-icons) 1281 | ;;(insert (all-the-icons-icon-for-buffer)) 1282 | (setq dashboard-center-content t) 1283 | (setq dashboard-image-banner-max-width 120) 1284 | (setq dashboard-image-banner-max-height 150) 1285 | (use-package page-break-lines) 1286 | (setq dashboard-set-heading-icons t) 1287 | (setq dashboard-set-file-icons t) 1288 | (setq dashboard-startup-banner "/Users/blaine/images/loxoSmall.png") 1289 | (setq dashboard-items '((recents . 20) 1290 | (bookmarks . 50) 1291 | (projects . 250) 1292 | (registers . 5))) 1293 | 1294 | ;; (agenda . 15) 1295 | ;; Set the title 1296 | ;;(setq dashboard-banner-logo-title "Dashboard of Blaine Mooers") 1297 | ;; Set the banner 1298 | ;;(setq dashboard-startup-banner 'official) 1299 | ;;(setq dashboard-startup-banner "/Users/blaine/Images/jmjd4alphaFOld1Aug30.png") 1300 | ;; Value can be 1301 | ;; 'official which displays the official emacs logo 1302 | ;; 'logo which displays an alternative emacs logo 1303 | ;; 1, 2 or 3 which displays one of the text banners 1304 | ;; "path/to/your/image.gif", "path/to/your/image.png" or "path/to/your/text.txt" which displays whatever gif/image/text you would prefer 1305 | 1306 | ;; Content is not centered by default. To center, set 1307 | ;;(setq dashboard-center-content t) 1308 | 1309 | ;; To disable shortcut "jump" indicators for each section, set 1310 | (setq dashboard-show-shortcuts nil) 1311 | 1312 | ; To show info about the packages loaded and the init time: 1313 | (setq dashboard-set-init-info t) 1314 | 1315 | ; To use it with counsel-projectile or persp-projectile 1316 | (setq dashboard-projects-switch-function 'projectile-persp-switch-project) 1317 | 1318 | ; To display today’s agenda items on the dashboard, add agenda to dashboard-items: 1319 | (add-to-list 'dashboard-items '(agenda) t) 1320 | 1321 | ; To show agenda for the upcoming seven days set the variable dashboard-week-agenda to t. 1322 | (setq dashboard-week-agenda t) 1323 | 1324 | 1325 | 1326 | ;; *** Dashboard refresh 1327 | ;; 1328 | ;; Function to refresh dashboard and open in the current window. 1329 | ;; This function is useful for accessing bookmarks and recent files created in the current session. 1330 | ;; The last line in the code bloack defines a global key binding to F1. 1331 | ;; 1332 | ;; Source of function by Jackson Benete Ferreira: the issues section of the [[https://github.com/emacs-dashboard/emacs-dashboard/issues/236][dashboard]] GitHub page. 1333 | ;; I edited the documentation line to fix the grammar and add the final phrase. 1334 | 1335 | 1336 | (defun new-dashboard () 1337 | "Jump to the dashboard buffer. If it doesn't exist, create one. Refresh while at it." 1338 | (interactive) 1339 | (switch-to-buffer dashboard-buffer-name) 1340 | (dashboard-mode) 1341 | (dashboard-insert-startupify-lists) 1342 | (dashboard-refresh-buffer)) 1343 | (global-set-key (kbd "") 'new-dashboard) 1344 | 1345 | 1346 | 1347 | (message "Finished package configurations D") 1348 | 1349 | 1350 | 1351 | (message "Start package configurations E") 1352 | ;;;# E 1353 | 1354 | ;;## ekg 1355 | ;; https://github.com/ahyatt/ekg?tab=readme-ov-file 1356 | ;; https://github.com/ahyatt/ekg/blob/develop/doc/ekg.org 1357 | ;; https://github.com/ahyatt/llm 1358 | ;; https://ollama.com/search?q=&c=embedding 1359 | ;; https://ollama.com/library 1360 | (use-package ekg 1361 | :bind (("C-c C-k" . ekg-capture)) 1362 | :init 1363 | (require 'ekg-embedding) 1364 | (ekg-embedding-generate-on-save) 1365 | (require 'ekg-llm) 1366 | (require 'llm-ollama) 1367 | :config 1368 | (require 'ekg-auto-save) 1369 | (add-hook 'ekg-capture-mode-hook #'ekg-auto-save-mode) 1370 | (add-hook 'ekg-edit-mode-hook #'ekg-auto-save-mode) 1371 | ) 1372 | ; (require 'llm-openai) ;; The specific provider you are using must be loaded. 1373 | ; (let ((my-provider (make-llm-openai :key "my-openai-api-key"))) 1374 | ; (setq ekg-llm-provider my-provider 1375 | ; ekg-embedding-provider my-provider))) 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | ;;## Embark 1382 | (use-package embark 1383 | :ensure t 1384 | :bind 1385 | (("C-." . embark-act) ;; pick some comfortable binding 1386 | ("M-." . embark-dwim) ;; good alternative: M-. 1387 | ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings' 1388 | 1389 | :init 1390 | 1391 | ;; Optionally replace the key help with a completing-read interface 1392 | (setq prefix-help-command #'embark-prefix-help-command) 1393 | 1394 | ;; Show the Embark target at point via Eldoc. You may adjust the Eldoc 1395 | ;; strategy, if you want to see the documentation from multiple providers. 1396 | (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target) 1397 | ;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly) 1398 | 1399 | :config 1400 | 1401 | ;; Hide the mode line of the Embark live/completions buffers 1402 | (add-to-list 'display-buffer-alist 1403 | '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" 1404 | nil 1405 | (window-parameters (mode-line-format . none))))) 1406 | 1407 | ;; Consult users will also want the embark-consult package. 1408 | (use-package embark-consult 1409 | :ensure t ; only need to install it, embark loads it after consult if found 1410 | :hook 1411 | (embark-collect-mode . consult-preview-at-point-mode)) 1412 | 1413 | (message "Finished package configurations E") 1414 | 1415 | (message "Started package configurations F") 1416 | (use-package flycheck 1417 | :ensure t) 1418 | 1419 | 1420 | (message "Finished package configurations F") 1421 | 1422 | (message "Started package configurations G") 1423 | ;;;# G 1424 | (use-package general) 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | 1431 | 1432 | (message "Start H packages configurations") 1433 | ; ;;;# 1434 | ;; major-mode-hydra 1435 | ;; source https://github.com/jerrypnz/major-mode-hydra.el 1436 | (use-package major-mode-hydra 1437 | :bind 1438 | ("s-SPC" . major-mode-hydra)) 1439 | 1440 | 1441 | (major-mode-hydra-define emacs-lisp-mode nil 1442 | ("Eval" 1443 | (("b" eval-buffer "buffer") 1444 | ("e" eval-defun "defun") 1445 | ("r" eval-region "region")) 1446 | "REPL" 1447 | (("I" ielm "ielm")) 1448 | "Test" 1449 | (("t" ert "prompt") 1450 | ("T" (ert t) "all") 1451 | ("F" (ert :failed) "failed")) 1452 | "Doc" 1453 | (("d" describe-foo-at-point "thing-at-pt") 1454 | ("f" describe-function "function") 1455 | ("v" describe-variable "variable") 1456 | ("i" info-lookup-symbol "info lookup")))) 1457 | 1458 | (message "Finished hydra package configurations") 1459 | 1460 | (message "Finished H package configurations") 1461 | 1462 | ;;*** helpful 1463 | 1464 | (use-package helpful) 1465 | 1466 | ;; Note that the built-in `describe-function' includes both functions 1467 | ;; and macros. `helpful-function' is functions only, so we provide 1468 | ;; `helpful-callable' as a drop-in replacement. 1469 | (global-set-key (kbd "C-h f") #'helpful-callable) 1470 | 1471 | (global-set-key (kbd "C-h v") #'helpful-variable) 1472 | (global-set-key (kbd "C-h k") #'helpful-key) 1473 | (global-set-key (kbd "C-h x") #'helpful-command) 1474 | 1475 | ;; Lookup the current symbol at point. C-c C-d is a common keybinding 1476 | ;; for this in lisp modes. 1477 | (global-set-key (kbd "C-c C-d") #'helpful-at-point) 1478 | 1479 | ;; Look up *F*unctions (excludes macros). 1480 | ;; 1481 | ;; By default, C-h F is bound to `Info-goto-emacs-command-node'. Helpful 1482 | ;; already links to the manual, if a function is referenced there. 1483 | (global-set-key (kbd "C-h F") #'helpful-function) 1484 | 1485 | (setq counsel-describe-function-function #'helpful-callable) 1486 | (setq counsel-describe-variable-function #'helpful-variable) 1487 | 1488 | 1489 | 1490 | 1491 | 1492 | 1493 | (message "Start I packages configurations") 1494 | ;;*** ivy 1495 | (use-package counsel) 1496 | (use-package ivy 1497 | :diminish ivy-mode 1498 | :config 1499 | (setq ivy-extra-directories nil) ;; Hides . and .. directories 1500 | (setq ivy-initial-inputs-alist nil) ;; Removes the ^ in ivy searches 1501 | ; (if (eq jib/computer 'laptop) 1502 | ; (setq-default ivy-height 10) 1503 | ; (setq-default ivy-height 11)) 1504 | (setq ivy-fixed-height-minibuffer t) 1505 | (add-to-list 'ivy-height-alist '(counsel-M-x . 7)) ;; Don't need so many lines for M-x, I usually know what command I want 1506 | 1507 | ;;(ivy-mode 1) 1508 | 1509 | ;; Shows a preview of the face in counsel-describe-face 1510 | (add-to-list 'ivy-format-functions-alist '(counsel-describe-face . counsel--faces-format-function)) 1511 | 1512 | :general 1513 | (general-define-key 1514 | ;; Also put in ivy-switch-buffer-map b/c otherwise switch buffer map overrides and C-k kills buffers 1515 | :keymaps '(ivy-minibuffer-map ivy-switch-buffer-map) 1516 | "S-SPC" 'nil 1517 | "C-SPC" 'ivy-restrict-to-matches ;; Default is S-SPC, changed this b/c sometimes I accidentally hit S-SPC 1518 | ;; C-j and C-k to move up/down in Ivy 1519 | "C-k" 'ivy-previous-line 1520 | "C-j" 'ivy-next-line) 1521 | ) 1522 | 1523 | 1524 | ;;;; Nice icons in Ivy. Replaces all-the-icons-ivy. 1525 | ;;(use-package all-the-icons-ivy-rich 1526 | ;; :init (all-the-icons-ivy-rich-mode 1) 1527 | ;; :config 1528 | ;; (setq all-the-icons-ivy-rich-icon-size 1.0)) 1529 | 1530 | ;; 1531 | (use-package ivy-rich 1532 | :after ivy 1533 | :init 1534 | (setq ivy-rich-path-style 'abbrev) 1535 | (setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line) 1536 | :config 1537 | (ivy-rich-mode 1)) 1538 | 1539 | 1540 | (use-package ivy-bibtex 1541 | :init 1542 | (setq bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 1543 | bibtex-completion-library-path '("/Users/blaine/0papersLabeled/" "/Users/blaine/0booksLabeled/") 1544 | bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 1545 | bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 1546 | bibtex-completion-additional-search-fields '(keywords) 1547 | bibtex-completion-display-formats 1548 | '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 1549 | (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 1550 | (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 1551 | (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 1552 | (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 1553 | bibtex-completion-pdf-open-function 1554 | (lambda (fpath) 1555 | (call-process "open" nil 0 nil fpath))) 1556 | ) 1557 | 1558 | (message "Finished I packages configurations") 1559 | 1560 | 1561 | 1562 | 1563 | (message "Started K packages configurations") 1564 | ;;;## Kind-Icon Configuration 1565 | (use-package kind-icon 1566 | :config 1567 | (setq kind-icon-default-face 'corfu-default) 1568 | (setq kind-icon-default-style '(:padding 0 :stroke 0 :margin 0 :radius 0 :height 0.9 :scale 1)) 1569 | (setq kind-icon-blend-frac 0.08) 1570 | (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter) 1571 | (add-hook 'counsel-load-theme #'(lambda () (interactive) (kind-icon-reset-cache))) 1572 | (add-hook 'load-theme #'(lambda () (interactive) (kind-icon-reset-cache)))) 1573 | 1574 | (message "Finished K packages configurations") 1575 | 1576 | 1577 | (message "Started L packages configurations") 1578 | (use-package llm 1579 | :load-path "/Users/blaine/e29org/manual-install/llm.git/" 1580 | :init 1581 | ) 1582 | 1583 | ; (use-package lsp-mode 1584 | ; :ensure t 1585 | ; :bind (:map lsp-mode-map 1586 | ; ("C-c d" . lsp-describe-thing-at-point) 1587 | ; ("C-c a" . lsp-execute-code-action)) 1588 | ; :bind-keymap ("C-c l" . lsp-command-map) 1589 | ; :config 1590 | ; (lsp-enable-which-key-integration t)) 1591 | ; :init 1592 | ; (setq lsp-auto-guess-root nil) 1593 | ; :hook (python-mode . lsp) 1594 | ; (latex-mode . lsp) 1595 | ; (lsp-mode . lsp-enable-which-key-integration) 1596 | ; :commands lsp) 1597 | 1598 | (use-package lsp-mode 1599 | :ensure t 1600 | :bind (:map lsp-mode-map 1601 | ("C-c d" . lsp-describe-thing-at-point) 1602 | ("C-c a" . lsp-execute-code-action)) 1603 | :bind-keymap ("C-c l" . lsp-command-map) 1604 | :config 1605 | (lsp-enable-which-key-integration t)) 1606 | 1607 | 1608 | 1609 | (use-package lsp-ui 1610 | :ensure t 1611 | :commands lsp-ui-mode) 1612 | 1613 | (use-package lsp-grammarly 1614 | :ensure t 1615 | :hook (text-mode . (lambda () 1616 | (require 'lsp-grammarly) 1617 | (lsp)))) ; or lsp-deferred 1618 | 1619 | 1620 | (use-package lsp-jedi 1621 | :ensure t) 1622 | 1623 | (use-package lsp-latex 1624 | :ensure t) 1625 | 1626 | ;; language-tool integration 1627 | (use-package lsp-ltex 1628 | :ensure t 1629 | :hook (text-mode . (lambda () 1630 | (require 'lsp-ltex) 1631 | (lsp))) ; or lsp-deferred 1632 | :init 1633 | (setq lsp-ltex-version "16.0.0")) ; make sure you have set this, see below 1634 | 1635 | 1636 | (message "Finished L packages configurations") 1637 | 1638 | (message "Start package configurations M") 1639 | ;;;# M 1640 | ;;;## Marginalia Configuration 1641 | (use-package marginalia 1642 | :ensure t 1643 | :config 1644 | (marginalia-mode)) 1645 | (customize-set-variable 'marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) 1646 | (marginalia-mode 1) 1647 | 1648 | ; This has become too expensive. 1649 | ; 1650 | ; (use-package mathpix.el 1651 | ; :load-path "manual-install/mathpix.el/" 1652 | ; :custom ((mathpix-app-id "JJhSopoRYlQ2Dz169a") 1653 | ; (mathpix-app-key "8cae6b1e-25aa-4c2c-8c90-e74cf6e6004e")) 1654 | ; :bind 1655 | ; ("C-x m" . mathpix-screenshot)) 1656 | 1657 | (use-package math-preview 1658 | :ensure t 1659 | :custom (math-preview-command "/Users/blaine/.nvm/versions/node/v22.4.0/lib/node_modules/math-preview/math-preview.js")) 1660 | 1661 | 1662 | (message "Finished M package configurations.") 1663 | 1664 | 1665 | (message "Start package configurations O.") 1666 | ;;;# O 1667 | 1668 | ;; Optionally use the `orderless' completion style. 1669 | (use-package orderless 1670 | :ensure t 1671 | :init 1672 | ;; Configure a custom style dispatcher (see the Consult wiki) 1673 | ;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch orderless-affix-dispatch) 1674 | ;; orderless-component-separator #'orderless-escapable-split-on-space) 1675 | (setq completion-styles '(orderless basic) 1676 | completion-category-defaults nil 1677 | completion-category-overrides '((file (styles partial-completion))))) 1678 | 1679 | 1680 | ;;;; Org configurations 1681 | 1682 | ; This setting enables changing the width the image in org. 1683 | (setq org-image-actual-width nil) 1684 | 1685 | ;;;## BEGINNING of org-agenda 1686 | (define-key org-mode-map (kbd "M-i") 'org-insert-item) 1687 | (setq org-agenda-start-with-log-mode t) 1688 | (setq org-log-done 'time) 1689 | (setq org-log-into-drawer t) 1690 | 1691 | (define-key global-map "\C-ca" 'org-agenda) 1692 | (setq org-log-done t) 1693 | ;; org-capture 1694 | (define-key global-map "\C-cc" 'org-capture) 1695 | (define-key global-map "\C-cl" 'org-store-link) 1696 | 1697 | (setq org-columns-default-format "%50ITEM(Task) %10CLOCKSUM %16TIMESTAMP_IA") 1698 | 1699 | (setq org-agenda-files '("/Users/blaine/gtd/tasks/JournalArticles.org" 1700 | "/Users/blaine/gtd/tasks/potentialWriting.org" 1701 | "/Users/blaine/gtd/tasks/Proposals.org" 1702 | "/Users/blaine/gtd/tasks/Books.org" 1703 | "/Users/blaine/gtd/tasks/Talks.org" 1704 | "/Users/blaine/gtd/tasks/Posters.org" 1705 | "/Users/blaine/gtd/tasks/ManuscriptReviews.org" 1706 | "/Users/blaine/gtd/tasks/Private.org" 1707 | "/Users/blaine/gtd/tasks/Service.org" 1708 | "/Users/blaine/gtd/tasks/Teaching.org" 1709 | "/Users/blaine/gtd/tasks/Workshops.org" 1710 | "/Users/blaine/gtd/tasks/springsem24.org" 1711 | "/Users/blaine/gtd/tasks/summersem24.org" 1712 | "/Users/blaine/gtd/tasks/fallsem24.org")) 1713 | (message "Finished org-agenda configuration. Line 5139.") 1714 | 1715 | 1716 | ;; Cycle through these keywords with shift right or left arrows. 1717 | (setq org-todo-keywords 1718 | '((sequence "TODO(t)" "INITIATED(i!)" "WAITING(w!)" "CAL(a)" "SOMEDAY(s!)" "PROJ(j)" "|" "DONE(d!)" "CANCELLED(c!)"))) 1719 | 1720 | (setq org-refile-targets '(("/Users/blaine/gtd/tasks/JournalArticles.org" :maxlevel . 2) 1721 | ("/Users/blaine/gtd/tasks/Proposals.org" :maxlevel . 2) 1722 | ("/Users/blaine/gtd/tasks/Books.org" :maxlevel . 2) 1723 | ("/Users/blaine/gtd/tasks/Talks.org" :maxlevel . 2) 1724 | ("/Users/blaine/gtd/tasks/Posters.org" :maxlevel . 2) 1725 | ("/Users/blaine/gtd/tasks/ManuscriptReviews.org" :maxlevel . 2) 1726 | ("/Users/blaine/gtd/tasks/Private.org" :maxlevel . 2) 1727 | ("/Users/blaine/gtd/tasks/Service.org" :maxlevel . 2) 1728 | ("/Users/blaine/gtd/tasks/Teaching.org" :maxlevel . 2) 1729 | ("/Users/blaine/gtd/tasks/grasscatcer.org" :maxlevel . 2) 1730 | ("/Users/blaine/gtd/tasks/Workshops.org" :maxlevel . 2) 1731 | ("/Users/blaine/gtd/tasks/december23.org" :maxlevel . 2) 1732 | ("/Users/blaine/gtd/tasks/springsem24.org" :maxlevel . 2) 1733 | ("/Users/blaine/gtd/tasks/summersem24.org" :maxlevel . 2) 1734 | ("/Users/blaine/gtd/tasks/fallsem24.org" :maxlevel . 2) 1735 | )) 1736 | (setq org-refile-use-outline-path 'file) 1737 | (message "Finished refile target configuration. Line 5162.") 1738 | 1739 | ;; ***** customized agenda views 1740 | ;; 1741 | ;; These are my customized agenda views by project. 1742 | ;; The letter is the last parameter. 1743 | ;; For example, enter ~C-c a b~ and then enter 402 at the prompt to list all active tasks related to 402 tasks. 1744 | ;; 1745 | ;; I learned about this approach [[https://tlestang.github.io/blog/keeping-track-of-tasks-and-projects-using-emacs-and-org-mode.html][here]]. 1746 | ;; 1747 | ;; The CATEGORY keyword resides inside of a Properties drawer. 1748 | ;; The drawers are usually closed. 1749 | ;; I am having trouble opening my drawers in may org files. 1750 | ;; In addition, I do not want to have to add a drawer to each TODO. 1751 | ;; 1752 | ;; I am loving Tags now. 1753 | ;; I may switch to using Tags because they are visible in org files. 1754 | ;; I tried and they are not leading to the expect list of TODOs in org-agenda. 1755 | ;; I am stumped. 1756 | ;; 1757 | ;; 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. 1758 | ;; 1759 | 1760 | (setq org-agenda-custom-commands 1761 | '( 1762 | ("b" 1763 | "List of all active 402 tasks." 1764 | tags-todo 1765 | "402\"/TODO|INITIATED|WAITING") 1766 | ("c" 1767 | "List of all active 523 RNA-drug crystallization review paper tasks." 1768 | tags-todo 1769 | "CATEGORY=\"523\"/TODO|INITIATED|WAITING") 1770 | ("d" 1771 | "List of all active 485PyMOLscGUI tasks." 1772 | tags-todo 1773 | "CATEGORY=\"485\"/TODO|INITIATED|WAITING") 1774 | ("e" 1775 | "List of all active 2104 Emacs tasks" 1776 | tags-todo 1777 | "2104+CATEGORY=\"2104\"/NEXT|TODO|INITIATED|WAITING") 1778 | ("n" 1779 | "List of all active 651 ENAX2 tasks" 1780 | tags-todo 1781 | "651+CATEGORY=\"651\"/NEXT|TODO|INITIATED|WAITING") 1782 | ("q" 1783 | "List of all active 561 charge density review" 1784 | tags 1785 | "561+CATEGORY=\"211\"/NEXT|TODO|INITIATED|WAITING") 1786 | ("r" 1787 | "List of all active 211 rcl/dnph tasks" 1788 | tags-todo 1789 | "211+CATEGORY=\"211\"/NEXT|TODO|INITIATED|WAITING") 1790 | ("P" 1791 | "List of all projects" 1792 | tags 1793 | "LEVEL=2/PROJ"))) 1794 | 1795 | (message "Finished org-agenda custum command configuration. Line 5220.") 1796 | ;; I usually know the project to which I want to assign a task. 1797 | ;; I loathe having to come back latter to refile my tasks. 1798 | ;; I want to do the filing at the time of capture. 1799 | ;; I found a solution [[https://stackoverflow.com/questions/9005843/interactively-enter-headline-under-which-to-place-an-entry-using-capture][here]]. 1800 | ;; 1801 | ;; A project has two or more tasks. 1802 | ;; I believe that the 10,000 projects is the upper limit for a 30 year academic career. 1803 | ;; There are about 10,000 workdays in a 30 year career if you work six days a week. 1804 | ;; Of course, most academics work seven a week and many work longer than 30 years, some even reach 60 years. 1805 | ;; 1806 | ;; I have my projects split into ten org files. 1807 | ;; Each org file has a limit of 1000 projects for ease of scrolling. 1808 | ;; 1809 | ;; It is best to let Emacs insert new task because it is easy to accidently delete sectons in an org file, especially when sections are folded. 1810 | ;; (I know that many love folded sections. 1811 | ;; There is a strong appeal to being able to collapse secitons of text. 1812 | ;; However, folded section are not for me; I have experienced too many catastrophes. 1813 | ;; I open all of my org files with all sections fully open. 1814 | ;; I can use swiper to navigate if I do not want to scroll.) 1815 | ;; Enter ~C-c c~ to start the capture menu. 1816 | ;; The settings below show a single letter option for selecting the appropriate org-file. 1817 | ;; After entering the single-letter code, you are prompted for the headline name. 1818 | ;; You do not have to include the TODO keyword. 1819 | ;; However, I changed "Headline" to "Tag" because I have the project ID was one of the tags on the same line as the project headline. 1820 | ;; I am now prompted for the tag. 1821 | ;; After entering the tag, I fill out the task entry. 1822 | ;; I then enter ~C-c C-c~ to save the capture. 1823 | ;; 1824 | ;;This protocol can be executed from inside the target org file or from a different buffer. 1825 | ;; 1826 | ;;I learned about the following function, which I modified by changing "Headline " to "Tag", from 1827 | ;;[[https://stackoverflow.com/questions/9005843/interactively-enter-headline-under-which-to-place-an-entry-using-capture][Lionel Henry]] with the modification by Phil on July 1, 2018. 1828 | ;; 1829 | (defun org-ask-location () 1830 | (let* ((org-refile-targets '((nil :maxlevel . 9))) 1831 | (hd (condition-case nil 1832 | (car (org-refile-get-location "Tag" nil t)) 1833 | (error (car org-refile-history))))) 1834 | (goto-char (point-min)) 1835 | (outline-next-heading) 1836 | (if (re-search-forward 1837 | (format org-complex-heading-regexp-format (regexp-quote hd)) 1838 | nil t) 1839 | (goto-char (point-at-bol)) 1840 | (goto-char (point-max)) 1841 | (or (bolp) (insert "\n")) 1842 | (insert "* " hd "\n"))) 1843 | (end-of-line)) 1844 | 1845 | 1846 | (setq org-capture-templates 1847 | '( 1848 | ("j" "JournalArticles" entry 1849 | (file+function "/Users/blaine/gtd/tasks/JournalArticles.org" org-ask-location) 1850 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1851 | :empty-lines 1) 1852 | ("g" "GrantProposals" entry 1853 | (file+function "/Users/blaine/gtd/tasks/Proposals.org" org-ask-location) 1854 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1855 | :empty-lines 1) 1856 | ("b" "Books" entry 1857 | (file+function "/Users/blaine/gtd/tasks/Books.org" org-ask-location) 1858 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1859 | :empty-lines 1) 1860 | ("t" "Talks" entry 1861 | (file+function "/Users/blaine/gtd/tasks/Talks.org" org-ask-location) 1862 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1863 | :empty-lines 1) 1864 | ("p" "Posters" entry 1865 | (file+function "/Users/blaine/gtd/tasks/Posters.org" org-ask-location) 1866 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1867 | :empty-lines 1) 1868 | ("r" "ManuscriptReviews" entry 1869 | (file+function "/Users/blaine/gtd/tasks/ManuscriptReviews.org" org-ask-location) 1870 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1871 | :empty-lines 1) 1872 | ("v" "Private" entry 1873 | (file+function "/Users/blaine/gtd/tasks/Private.org" org-ask-location) 1874 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1875 | :empty-lines 1) 1876 | ("S" "Service" entry 1877 | (file+function "/Users/blaine/gtd/tasks/Service.org" org-ask-location) 1878 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1879 | :empty-lines 1) 1880 | ("T" "Teaching" entry 1881 | (file+function "/Users/blaine/gtd/tasks/Teaching.org" org-ask-location) 1882 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1883 | :empty-lines 1) 1884 | ("w" "Workshop" entry 1885 | (file+function "/Users/blaine/gtd/tasks/Workshops.org" org-ask-location) 1886 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1887 | :empty-lines 1) 1888 | ("d" "December" entry 1889 | (file+function "/Users/blaine/gtd/tasks/december23.org" org-ask-location) 1890 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1891 | :empty-lines 1) 1892 | ("s" "springsem24" entry 1893 | (file+function "/Users/blaine/gtd/tasks/springsem24.org" org-ask-location) 1894 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1895 | :empty-lines 1) 1896 | ("u" "springsem24" entry 1897 | (file+function "/Users/blaine/gtd/tasks/summersem24.org" org-ask-location) 1898 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1899 | :empty-lines 1) 1900 | ("f" "fallsem24" entry 1901 | (file+function "/Users/blaine/gtd/tasks/fallsem24.org" org-ask-location) 1902 | "\n\n*** TODO %?\n<%<%Y-%m-%d %a %T>>" 1903 | :empty-lines 1) 1904 | ("x" "Slipbox" entry (file "/User/org-roam/inbox.org") 1905 | "* %?\n") 1906 | )) 1907 | (defun jethro/org-capture-slipbox () 1908 | (interactive) 1909 | (org-capture nil "s")) 1910 | 1911 | 1912 | (message "Finished org-agenda configuration. Line 1432.") 1913 | ;; <<<<<<< END of org-agenda >>>>>>>>>>>>>> 1914 | 1915 | ;; https://github.com/shg/ob-julia-vterm.el 1916 | ;;(add-to-list 'org-babel-load-languages '(julia-vterm . t)) 1917 | 1918 | 1919 | ;;;### org-ai 1920 | 1921 | ; (use-package org-ai 1922 | ; :load-path "/Users/blaine/emacs29.3/manual-packages/org-ai/" 1923 | ; :commands (org-ai-mode 1924 | ; org-ai-global-mode) 1925 | ; :init 1926 | ; (add-hook 'org-mode-hook #'org-ai-mode) ; enable org-ai in org-mode 1927 | ; (org-ai-global-mode) ; installs global keybindings on C-c M-a 1928 | ; :config 1929 | ; (setq org-ai-default-chat-model "gpt-4") ; if you are on the gpt-4 beta: 1930 | ; (org-ai-install-yasnippets)) ; if you are using yasnippet and want `ai` snippets 1931 | 1932 | (message "Started org-babel configuration. Line 1452.") 1933 | ;;;### org-babel 1934 | (org-babel-do-load-languages 1935 | 'org-babel-load-languages 1936 | '((emacs-lisp . t) 1937 | (shell . t) 1938 | (c . nil) 1939 | (cpp . nil) 1940 | (clojure . t) 1941 | (F90 . nil) 1942 | (gnuplot . t) 1943 | (js . nil) 1944 | (ditaa . nil) 1945 | (java . t) 1946 | (mathematica . nil) 1947 | (plantuml . nil) 1948 | (lisp . t) 1949 | (org . t) 1950 | (julia . t) 1951 | (python . t) 1952 | (R . t) 1953 | (jupyter . t)) 1954 | ) 1955 | 1956 | ;; Removed (jupyter . t) on May 14 due to an error message. 1957 | ;; (jupyter . t)) 1958 | ;; By default, you need to specify julia-vterm as the language name for source blocks. 1959 | ;; To use julia as the language name, define the following aliases. 1960 | 1961 | ;; (defalias 'org-babel-execute:julia 'org-babel-execute:julia-vterm) 1962 | ;; (defalias 'org-babel-variable-assignments:julia 'org-babel-variable-assignments:julia-vterm) 1963 | (message "Finished org-babel configuration. Line 1496.") 1964 | 1965 | ;;*** org-cc 1966 | ;; Context clues 1967 | ;; source https://github.com/durableOne/org-cc 1968 | (add-to-list 'load-path "/Users/blaine/emacs29.3/manual-packages/org-cc") 1969 | (use-package org-cc 1970 | :ensure nil 1971 | :after org 1972 | :custom 1973 | (org-cc-directory (concat org-directory "org-cc")) ;; subdirectory of the heading's attachment directory 1974 | (org-cc-days 14) 1975 | :init 1976 | (add-hook 'org-clock-in-hook #'org-cc-display-notes) 1977 | ) 1978 | (global-set-key (kbd "C-c k") 'org-cc-edit-cc-file) 1979 | (global-set-key (kbd "C-c x") 'org-cc-display-notes) 1980 | 1981 | (message "Finished org-cc. Line 15--.") 1982 | ;; org-caputre templates 1983 | 1984 | (setq org-capture-templates 1985 | '(("r" "Record" 1986 | plain 1987 | (file "/Users/blaine/org/notes.org") 1988 | "* %^{Title} :%^{Tags}:\n%U%i\n%?\n"))) 1989 | 1990 | (global-set-key (kbd "C-c t") 'org-tags-view) 1991 | (message "Finished org-capture configuration. Line 1526.") 1992 | 1993 | 1994 | ; (use-package org-gtd 1995 | ; :after org 1996 | ; :quelpa (org-gtd :fetcher github :repo "trevoke/org-gtd.el" 1997 | ; :commit "3.0.0" :upgrade t) 1998 | ; :demand t 1999 | ; :custom 2000 | ; (org-gtd-directory "~/org-gtd") 2001 | ; (org-edna-use-inheritance t) 2002 | ; (org-gtd-organize-hooks '(org-gtd-set-area-of-focus org-set-tags-command)) 2003 | ; :config 2004 | ; (org-edna-mode) 2005 | ; :bind 2006 | ; (("C-c d c" . org-gtd-capture) 2007 | ; ("C-c d e" . org-gtd-engage) 2008 | ; ("C-c d p" . org-gtd-process-inbox) 2009 | ; :map org-gtd-clarify-map 2010 | ; ("C-c c" . org-gtd-organize))) 2011 | 2012 | 2013 | (message "Started org-noter configuration. Line 1530.") 2014 | (use-package org-noter) 2015 | ;;*** Org-pdf-noter 2016 | ;; This commented out config sort of worked. 2017 | (use-package org-noter 2018 | :after org 2019 | :config 2020 | ;; Your org-noter config ........ 2021 | :config 2022 | (setq 2023 | org_notes (concat (getenv "HOME") "/org-roam/") 2024 | zot_bib (concat (getenv "HOME") "/Documents/global.bib") 2025 | org-directory org_notes 2026 | deft-directory org_notes 2027 | org-roam-directory org_notes 2028 | ;; keep an empty line between headings and content in Org file 2029 | org-noter-separate-notes-from-heading t) 2030 | (require 'org-noter-pdftools)) 2031 | 2032 | (use-package org-pdftools 2033 | :hook (org-mode . org-pdftools-setup-link)) 2034 | 2035 | 2036 | (use-package org-noter-pdftools 2037 | :after org-noter 2038 | :config 2039 | ;; Add a function to ensure precise note is inserted 2040 | (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions) 2041 | (interactive "P") 2042 | (org-noter--with-valid-session 2043 | (let ((org-noter-insert-note-no-questions (if toggle-no-questions 2044 | (not org-noter-insert-note-no-questions) 2045 | org-noter-insert-note-no-questions)) 2046 | (org-pdftools-use-isearch-link t) 2047 | (org-pdftools-use-freepointer-annot t)) 2048 | (org-noter-insert-note (org-noter--get-precise-info))))) 2049 | 2050 | ;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf 2051 | (defun org-noter-set-start-location (&optional arg) 2052 | "When opening a session with this document, go to the current location. 2053 | With a prefix ARG, remove start location." 2054 | (interactive "P") 2055 | (org-noter--with-valid-session 2056 | (let ((inhibit-read-only t) 2057 | (ast (org-noter--parse-root)) 2058 | (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive)))) 2059 | (with-current-buffer (org-noter--session-notes-buffer session) 2060 | (org-with-wide-buffer 2061 | (goto-char (org-element-property :begin ast)) 2062 | (if arg 2063 | (org-entry-delete nil org-noter-property-note-location) 2064 | (org-entry-put nil org-noter-property-note-location 2065 | (org-noter--pretty-print-location location)))))))) 2066 | (with-eval-after-load 'pdf-annot 2067 | (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note))) 2068 | 2069 | (use-package pdf-tools-org-noter-helpers 2070 | :pin manual 2071 | :load-path "/Users/blaine/emacs29.3/manual-packages/pdf-tools-org-noter-helpers/") 2072 | 2073 | 2074 | ;;*** org-pomodoro 2075 | ;; (shell-command-to-string "open -a tomighty.app") 2076 | (use-package org-pomodoro 2077 | :commands (org-pomodoro) 2078 | :config 2079 | (setq alert-user-configuration (quote ((((:category . "org-pomodoro")) libnotify nil))))) 2080 | 2081 | ;; add hook to enable automated start of the next pom after a break. 2082 | ;; Source: https://github.com/marcinkoziej/org-pomodoro/issues/32 2083 | ;; (add-hook 'org-pomodoro-break-finished-hook 2084 | ;; (lambda () 2085 | ;; (interactive) 2086 | ;; (point-to-register 1) 2087 | ;; (org-clock-goto) 2088 | ;; (org-pomodoro '(25)) 2089 | ;; (register-to-point 1) 2090 | ;; (shell-command-to-string "open -a tomighty.app") 2091 | ;; )) 2092 | 2093 | (use-package sound-wav) 2094 | (setq org-pomodoro-ticking-sound-p nil) 2095 | (setq org-pomodoro-ticking-sound-states '(:pomodoro :short-break :long-break)) 2096 | (setq org-pomodoro-ticking-sound-states '(:pomodoro)) 2097 | (setq org-pomodoro-ticking-frequency 1) 2098 | (setq org-pomodoro-audio-player "mplayer") 2099 | (setq org-pomodoro-finished-sound-args "-volume 0.9") 2100 | (setq org-pomodoro-long-break-sound-args "-volume 0.9") 2101 | (setq org-pomodoro-short-break-sound-args "-volume 0.9") 2102 | (setq org-pomodoro-ticking-sound-args "-volume 0.3") 2103 | 2104 | (global-set-key (kbd "C-c o") 'org-pomodoro) 2105 | (message "Finished org-pomodoros configuration. Line 1607.") 2106 | 2107 | 2108 | ; (message "Start org-ref configuration. Line 1610.") 2109 | ; ;; John Kitchin's config on YouTube https://www.youtube.com/watch?v=3u6eTSzHT6s 2110 | ; ; (use-package ivy-bibtex 2111 | ; ; :init 2112 | ; ; (setq bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 2113 | ; ; bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 2114 | ; ; bibtex-completion-additional-search-fields '(keywords) 2115 | ; ; bibtex-completion-display-formats 2116 | ; ; '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 2117 | ; ; (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 2118 | ; ; (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2119 | ; ; (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2120 | ; ; (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 2121 | ; ; bibtex-completion-pdf-open-function 2122 | ; ; (lambda (fpath) 2123 | ; ; (call-process "open" nil 0 nil fpath))) 2124 | ; ; ) 2125 | 2126 | 2127 | ;; org-ref 2128 | ;; Set the case of the Author and Title to Capitalize with customize. 2129 | (use-package org-ref 2130 | :init 2131 | (use-package bibtex) 2132 | (setq bibtex-autokey-year-length 4 2133 | bibtex-autokey-name-year-separator "" 2134 | bibtex-autokey-year-title-separator "" 2135 | bibtex-autokey-titleword-separator "" 2136 | bibtex-autokey-titlewords 9 2137 | bibtex-autokey-titlewords-stretch 9 2138 | bibtex-autokey-titleword-length 15) 2139 | ;; H is the hyper key. I have bound H to Fn. For the MacAlly keyboard, it is bound to right-command. 2140 | (define-key bibtex-mode-map (kbd "H-b") 'org-ref-bibtex-hydra/body) 2141 | ;; (use-package org-ref-ivy) 2142 | (setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body 2143 | org-ref-insert-cite-function 'org-ref-cite-insert-ivy 2144 | org-ref-insert-label-function 'org-ref-insert-label-link 2145 | org-ref-insert-ref-function 'org-ref-insert-ref-link 2146 | org-ref-cite-onclick-function (lambda (_) (org-ref-citation-hydra/body))) 2147 | ; (use-package org-ref-arxiv) 2148 | ; (use-package org-ref-pubmed) 2149 | ; (use-package org-ref-wos) 2150 | ) 2151 | 2152 | 2153 | (message "Start bibtex-completion-bibliography configuration of org-ref. Line 1656.") 2154 | 2155 | (setq bibtex-completion-bibliography '("/Users/blaine/Documents/global.bib") 2156 | bibtex-completion-library-path '("/Users/blaine/0papersLabeled/" "/Users/blaine/0booksLabeled/") 2157 | bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 2158 | bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 2159 | bibtex-completion-additional-search-fields '(keywords) 2160 | bibtex-completion-display-formats 2161 | '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 2162 | (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 2163 | (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2164 | (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2165 | (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 2166 | bibtex-completion-pdf-open-function 2167 | (lambda (fpath) 2168 | (call-process "open" nil 0 nil fpath))) 2169 | 2170 | (setq bibtex-autokey-year-length 4 2171 | bibtex-autokey-name-year-separator "-" 2172 | bibtex-autokey-year-title-separator "-" 2173 | bibtex-autokey-titleword-separator "-" 2174 | bibtex-autokey-titlewords 2 2175 | bibtex-autokey-titlewords-stretch 1 2176 | bibtex-autokey-titleword-length 5) 2177 | (message "Finished bibtex-completion-bibliography configuration of org-ref. Line 1691.") 2178 | 2179 | ;; H is the hyper key. I have bound H to Fn. For the MacAlly keyboard, it is bound to right-command. 2180 | (define-key bibtex-mode-map (kbd "s-b") 'org-ref-bibtex-hydra/body) 2181 | (define-key org-mode-map (kbd "s-i") org-ref-insert-cite-function) 2182 | (define-key org-mode-map (kbd "s-r") org-ref-insert-ref-function) 2183 | (define-key org-mode-map (kbd "H-l") org-ref-insert-label-function) 2184 | (define-key org-mode-map (kbd "H-d") 'doi-add-bibtex-entry) 2185 | 2186 | ;; to use org-cite-insert 2187 | (setq org-ref-insert-cite-function 2188 | (lambda () 2189 | (org-cite-insert nil))) 2190 | 2191 | ;; <<<<<<< END org-ref >>>>>>>>>>>>>> 2192 | (message "Finished org-cite configurations") 2193 | 2194 | 2195 | 2196 | 2197 | (message "Start org-roam configurations") 2198 | ;; <<<<<<< BEGIN org-roam >>>>>>>>>>>>>> 2199 | 2200 | ;; ** Basic org-roam config 2201 | (use-package org-roam 2202 | :custom 2203 | (org-roam-directory (file-truename "/Users/blaine/org-roam/")) 2204 | :bind (("C-c n l" . org-roam-buffer-toggle) 2205 | ("C-c n f" . org-roam-node-find) 2206 | ("C-c n g" . org-roam-graph) 2207 | ("C-c n i" . org-roam-node-insert) 2208 | ("C-c n c" . #'org-id-get-create) 2209 | ;; Dailies 2210 | ("C-c n j" . org-roam-dailies-capture-today)) 2211 | :config 2212 | ;; If you're using a vertical completion framework, you might want a more informative completion interface 2213 | (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 2214 | (org-roam-db-autosync-mode)) 2215 | ;;(org-roam-ui-mode)) 2216 | ;; If using org-roam-protocol 2217 | ;;(use-package org-roam-protocol)) 2218 | 2219 | 2220 | ;; Following https://jethrokuan.github.io/org-roam-guide/ 2221 | (message "Start org-roam-capture template configurations, line 1721") 2222 | 2223 | (setq org-roam-capture-templates 2224 | '(("p" "permanent" plain 2225 | "%?" 2226 | :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") 2227 | :immediate-finish t 2228 | :unnarrowed t) 2229 | ;; citar literature note 2230 | ; ("n" "literature note" plain 2231 | ; "%?" 2232 | ; :target (file+head "%(expand-file-name (or citar-org-roam-subdir \"\") org-roam-directory)/${citar-citekey}.org" 2233 | ; "#+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") 2234 | ; :unnarrowed t) 2235 | ("r" "reference" plain "%?" 2236 | :if-new 2237 | (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") 2238 | :immediate-finish t 2239 | :unnarrowed t) 2240 | ("l" "clipboard" plain #'org-roam-capture--get-point "%i%a" 2241 | :file-name "%<%Y%m%d%H%M%S>-${slug}" 2242 | :head "#+title: ${title}\n#+created: %u\n#+last_modified: %U\n#+ROAM_TAGS: %?" 2243 | :unnarrowed t 2244 | :prepend t 2245 | :jump-to-captured t) 2246 | ;; Vidianos G's config with ivy-bibtex 2247 | ("v" "bibliography reference" plain 2248 | "%?" 2249 | : if-new 2250 | (file+head "ref/${citekey}.org" "#+title: ${title}\n 2251 | ,#+filetags: ${entry-type} 2252 | - keywords :: ${keywords} 2253 | - tags :: 2254 | 2255 | ,* Analysis of ${entry-type} by ${author} 2256 | 2257 | 2258 | 2259 | * References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n 2260 | :PROPERTIES: 2261 | :URL: ${Url} 2262 | :NOTER_DOCUMENT: ${file} 2263 | :NOTER_PAGE: 2264 | :END:") 2265 | :unnarrowed t 2266 | :jump-to-captured t) 2267 | ("b" "bibliography notes" plain ; Org-noter integration 2268 | (file "~/org-roam/references/notes/notes-template.org") 2269 | :target (file+head "references/notes/${citekey}.org" 2270 | "#+title: ${title}\n :article:\n\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 2271 | :empty-lines 1) 2272 | ("a" "article" plain "%?" 2273 | :if-new 2274 | (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") 2275 | :immediate-finish t 2276 | :unnarrowed t))) 2277 | 2278 | (setq org-roam-node-display-template 2279 | (concat "${type:15} ${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 2280 | 2281 | 2282 | ;; Writing technical documents requires us to write in paragraphs, 2283 | ;; whereas org mode by default is intended to be used as an outliner, 2284 | ;; to get around this problem, setting up org-export to preserve line breaks is useful 2285 | ;; (setq org-export-preserve-breaks t) 2286 | (message "End org-roam package configurations, line 1785") 2287 | 2288 | 2289 | ;; 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. 2290 | ;; 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. 2291 | ;; Put multiline code from mathpix between double dollar signs and treat as being on one line. 2292 | ;; This trick does not work with the equation environment compressed to one line. You have to use M-x math-preview-region. 2293 | ;; 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 2294 | ;; 2295 | ;; I ran out of time to time out how to render an active region. I need to find the analog of the latex-fragment: 2296 | ;; ('latex-???? (math-preview-region)) 2297 | ;; ???? has to be some kind of an org-element-type. org-latex-section does not work. 2298 | ;; This would enable using this application of the math-preview-region to render equation environments. 2299 | 2300 | 2301 | (defun bhmm/toggle-state-at-point () 2302 | (interactive) 2303 | (let ((ctx (org-element-context))) 2304 | (pcase (org-element-type ctx) 2305 | ('link (org-toggle-link-display)) 2306 | ('latex-fragment (math-preview-at-point))))) 2307 | 2308 | (define-key org-mode-map (kbd "C-c t") #'bhmm/toggle-state-at-point) 2309 | 2310 | (message "End toggle-state-at-point for use with images and equations.") 2311 | 2312 | 2313 | (message "End package configurations O") 2314 | 2315 | 2316 | (message "Start package configurations P") 2317 | ;;;# P 2318 | (use-package pdf-tools 2319 | :pin manual ;; manually update 2320 | :config 2321 | ;; initialise 2322 | (pdf-tools-install) 2323 | ;; open pdfs scaled to fit width 2324 | (setq-default pdf-view-display-size 'fit-width) 2325 | ;; use normal isearch 2326 | (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward) 2327 | :custom 2328 | (pdf-annot-activate-created-annotations t "automatically annotate highlights")) 2329 | 2330 | ;; per frame workspaces like on the Macs spaces 2331 | (use-package perspective 2332 | :ensure t 2333 | :bind 2334 | ("C-x C-b" . persp-list-buffers) ; or use a nicer switcher, see below 2335 | :custom 2336 | (persp-mode-prefix-key (kbd "C-c M-p")) ; pick your own prefix key here 2337 | :init 2338 | (persp-mode)) 2339 | (message "End package configurations P") 2340 | 2341 | 2342 | (message "Start package configurations S") 2343 | ;;;# S 2344 | ;;*** serenade (source: https://github.com/justin-roche/serenade-mode) 2345 | (use-package serenade-mode 2346 | :load-path "/Users/blaine/e29org/manual-install/serenade-mode/") 2347 | 2348 | (setq serenade-completion-frontend 'helm) 2349 | (setq serenade-helm-M-x t) 2350 | (setq serenade-snippet-engine 'yasnippet) 2351 | 2352 | (message "End package configurations S") 2353 | 2354 | 2355 | (message "Start package configurations T") 2356 | 2357 | ;; C-x t t to launch treemacs 2358 | ;; Support dragging files from the treemacs directory to a buffer to open them. 2359 | ;; Default configuration for treemacs minus the treemacs-evil pacakge. 2360 | ;; 2361 | (use-package treemacs 2362 | :ensure t 2363 | :defer t 2364 | :init 2365 | (with-eval-after-load 'winum 2366 | (define-key winum-keymap (kbd "M-0") #'treemacs-select-window)) 2367 | :config 2368 | (progn 2369 | (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) 2370 | treemacs-deferred-git-apply-delay 0.5 2371 | treemacs-directory-name-transformer #'identity 2372 | treemacs-display-in-side-window t 2373 | treemacs-eldoc-display 'simple 2374 | treemacs-file-event-delay 2000 2375 | treemacs-file-extension-regex treemacs-last-period-regex-value 2376 | treemacs-file-follow-delay 0.2 2377 | treemacs-file-name-transformer #'identity 2378 | treemacs-follow-after-init t 2379 | treemacs-expand-after-init t 2380 | treemacs-find-workspace-method 'find-for-file-or-pick-first 2381 | treemacs-git-command-pipe "" 2382 | treemacs-goto-tag-strategy 'refetch-index 2383 | treemacs-header-scroll-indicators '(nil . "^^^^^^") 2384 | treemacs-hide-dot-git-directory t 2385 | treemacs-indentation 2 2386 | treemacs-indentation-string " " 2387 | treemacs-is-never-other-window nil 2388 | treemacs-max-git-entries 5000 2389 | treemacs-missing-project-action 'ask 2390 | treemacs-move-files-by-mouse-dragging t 2391 | treemacs-move-forward-on-expand nil 2392 | treemacs-no-png-images nil 2393 | treemacs-no-delete-other-windows t 2394 | treemacs-project-follow-cleanup nil 2395 | treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) 2396 | treemacs-position 'left 2397 | treemacs-read-string-input 'from-child-frame 2398 | treemacs-recenter-distance 0.1 2399 | treemacs-recenter-after-file-follow nil 2400 | treemacs-recenter-after-tag-follow nil 2401 | treemacs-recenter-after-project-jump 'always 2402 | treemacs-recenter-after-project-expand 'on-distance 2403 | treemacs-litter-directories '("/node_modules" "/.venv" "/.cask") 2404 | treemacs-project-follow-into-home nil 2405 | treemacs-show-cursor nil 2406 | treemacs-show-hidden-files t 2407 | treemacs-silent-filewatch nil 2408 | treemacs-silent-refresh nil 2409 | treemacs-sorting 'alphabetic-asc 2410 | treemacs-select-when-already-in-treemacs 'move-back 2411 | treemacs-space-between-root-nodes t 2412 | treemacs-tag-follow-cleanup t 2413 | treemacs-tag-follow-delay 1.5 2414 | treemacs-text-scale nil 2415 | treemacs-user-mode-line-format nil 2416 | treemacs-user-header-line-format nil 2417 | treemacs-wide-toggle-width 70 2418 | treemacs-width 35 2419 | treemacs-width-increment 1 2420 | treemacs-width-is-initially-locked t 2421 | treemacs-workspace-switch-cleanup nil) 2422 | 2423 | ;; The default width and height of the icons is 22 pixels. If you are 2424 | ;; using a Hi-DPI display, uncomment this to double the icon size. 2425 | ;;(treemacs-resize-icons 44) 2426 | 2427 | (treemacs-follow-mode t) 2428 | (treemacs-filewatch-mode t) 2429 | (treemacs-fringe-indicator-mode 'always) 2430 | (when treemacs-python-executable 2431 | (treemacs-git-commit-diff-mode t)) 2432 | 2433 | (pcase (cons (not (null (executable-find "git"))) 2434 | (not (null treemacs-python-executable))) 2435 | (`(t . t) 2436 | (treemacs-git-mode 'deferred)) 2437 | (`(t . _) 2438 | (treemacs-git-mode 'simple))) 2439 | 2440 | (treemacs-hide-gitignored-files-mode nil)) 2441 | :bind 2442 | (:map global-map 2443 | ("M-0" . treemacs-select-window) 2444 | ("C-x t 1" . treemacs-delete-other-windows) 2445 | ("C-x t t" . treemacs) 2446 | ("C-x t d" . treemacs-select-directory) 2447 | ("C-x t B" . treemacs-bookmark) 2448 | ("C-x t C-t" . treemacs-find-file) 2449 | ("C-x t M-t" . treemacs-find-tag))) 2450 | 2451 | (use-package treemacs-projectile 2452 | :after (treemacs projectile) 2453 | :ensure t) 2454 | 2455 | (use-package treemacs-icons-dired 2456 | :hook (dired-mode . treemacs-icons-dired-enable-once) 2457 | :ensure t) 2458 | 2459 | ; (use-package treemacs-magit 2460 | ; :after (treemacs magit) 2461 | ; :ensure t) 2462 | 2463 | (use-package treemacs-persp ;;treemacs-perspective if you use perspective.el vs. persp-mode 2464 | :after (treemacs persp-mode) ;;or perspective vs. persp-mode 2465 | :ensure t 2466 | :config (treemacs-set-scope-type 'Perspectives)) 2467 | 2468 | ; (use-package treemacs-tab-bar ;;treemacs-tab-bar if you use tab-bar-mode 2469 | ; :after (treemacs) 2470 | ; :ensure t 2471 | ; :config (treemacs-set-scope-type 'Tabs)) 2472 | 2473 | (treemacs-start-on-boot) 2474 | 2475 | 2476 | 2477 | 2478 | (use-package triples 2479 | :load-path "/Users/blaine/e29org/manual-install/triples/") 2480 | 2481 | (message "End package configurations T") 2482 | 2483 | 2484 | (message "Start package configurations U") 2485 | 2486 | (use-package undo-tree 2487 | :ensure t 2488 | :config 2489 | (global-undo-tree-mode 1)) 2490 | 2491 | (message "End package configurations U") 2492 | 2493 | 2494 | (message "Start package configurations V") 2495 | ;;;# V 2496 | ;;;## Vertico Configuration 2497 | (use-package vertico 2498 | :ensure t 2499 | :init 2500 | (vertico-mode) 2501 | 2502 | ;; Different scroll margin 2503 | ;; (setq vertico-scroll-margin 0) 2504 | 2505 | ;; Show more candidates 2506 | (setq vertico-count 20) 2507 | 2508 | ;; Grow and shrink the Vertico minibuffer 2509 | (setq vertico-resize t) 2510 | 2511 | ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. 2512 | (setq vertico-cycle t) 2513 | ) 2514 | 2515 | ;; Persist history over Emacs restarts. Vertico sorts by history position. 2516 | (use-package savehist 2517 | :ensure t 2518 | :init 2519 | (savehist-mode)) 2520 | 2521 | ;; A few more useful configurations... 2522 | (use-package emacs 2523 | :ensure t 2524 | :init 2525 | ;; Add prompt indicator to `completing-read-multiple'. 2526 | ;; We display [CRM], e.g., [CRM,] if the separator is a comma. 2527 | (defun crm-indicator (args) 2528 | (cons (format "[CRM%s] %s" 2529 | (replace-regexp-in-string 2530 | "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" 2531 | crm-separator) 2532 | (car args)) 2533 | (cdr args))) 2534 | (advice-add #'completing-read-multiple :filter-args #'crm-indicator) 2535 | 2536 | ;; Do not allow the cursor in the minibuffer prompt 2537 | (setq minibuffer-prompt-properties 2538 | '(read-only t cursor-intangible t face minibuffer-prompt)) 2539 | (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) 2540 | 2541 | ;; Emacs 28: Hide commands in M-x which do not work in the current mode. 2542 | ;; Vertico commands are hidden in normal buffers. 2543 | ;; (setq read-extended-command-predicate 2544 | ;; #'command-completion-default-include-p) 2545 | 2546 | ;; Enable recursive minibuffers 2547 | (setq enable-recursive-minibuffers t)) 2548 | 2549 | 2550 | (message "Start package configurations W") 2551 | ;;;## which-key 2552 | (use-package which-key 2553 | :ensure t 2554 | :init 2555 | :defer 0 2556 | :diminish which-key-mode 2557 | :config 2558 | (which-key-mode) 2559 | (setq which-key-idle-delay 0.3)) 2560 | ;; (add-hook 'c-mode-hook 'lsp) 2561 | ;; (add-hook 'c++-mode-hook 'lsp) 2562 | (add-hook 'clojure-mode-hook 'lsp) 2563 | ;; (add-hook 'julia-mode-hook 'lsp) 2564 | (add-hook 'latex-mode-hook 'lsp) 2565 | (add-hook 'python-mode-hook 'lsp) 2566 | ;; (add-hook 'R-mode-hook 'lsp) 2567 | (which-key-setup-side-window-right-bottom) 2568 | 2569 | 2570 | (message "End package configurations W") 2571 | 2572 | (message "Start package configurations Y") 2573 | 2574 | (use-package yasnippet 2575 | :config 2576 | (yas-global-mode 1)) 2577 | (global-set-key "\C-o" 'yas-expand) 2578 | (global-set-key "\C-c y i" 'yas-insert-snippet) 2579 | (global-set-key "\C-c y n" 'yas-new-snippet) 2580 | 2581 | 2582 | ;;;### my-hydras 2583 | ;; load hydras 2584 | ;;(use-package talon-quiz-hydra 2585 | ;; :load-path "~/emacs29.3/my-hydras/") 2586 | ;;(global-set-key (kbd "C-c 9") 'talon-quiz-hydra/body) 2587 | 2588 | (use-package writing-projects-hydra 2589 | :load-path "~/emacs29.3/my-hydras/") 2590 | (global-set-key (kbd "C-c 9") 'writing-projects-hydra/body) 2591 | 2592 | (use-package learning-packages-and-modes-hydras 2593 | :load-path "~/emacs29.3/my-hydras/") 2594 | (global-set-key (kbd "C-c 2") 'learning-packages-and-modes-hydras/body) 2595 | 2596 | (use-package learning-spiral-hydras 2597 | :load-path "~/emacs29.3/my-hydras/") 2598 | (global-set-key (kbd "C-c 1") 'hydra-of-learning-spiral/body) 2599 | 2600 | (use-package my-hydras 2601 | :load-path "~/emacs29.3/my-hydras/") 2602 | (global-set-key (kbd "C-c 0") 'hydra-of-hydras/body) 2603 | 2604 | 2605 | 2606 | ;; A cool hydra for finding snippets at point. Invoke with C-c y. 2607 | (use-package hydra 2608 | :defer 2 2609 | :bind ("C-c y" . hydra-yasnippet/body)) 2610 | 2611 | (use-package popup) 2612 | ;; add some shotcuts in popup menu mode 2613 | (define-key popup-menu-keymap (kbd "M-n") 'popup-next) 2614 | (define-key popup-menu-keymap (kbd "TAB") 'popup-next) 2615 | (define-key popup-menu-keymap (kbd "") 'popup-next) 2616 | (define-key popup-menu-keymap (kbd "") 'popup-previous) 2617 | (define-key popup-menu-keymap (kbd "M-p") 'popup-previous) 2618 | 2619 | (defun yas/popup-isearch-prompt (prompt choices &optional display-fn) 2620 | (when (featurep 'popup) 2621 | (popup-menu* 2622 | (mapcar 2623 | (lambda (choice) 2624 | (popup-make-item 2625 | (or (and display-fn (funcall display-fn choice)) 2626 | choice) 2627 | :value choice)) 2628 | choices) 2629 | :prompt prompt 2630 | ;; start isearch mode immediately 2631 | :isearch t 2632 | ))) 2633 | (setq yas/prompt-functions '(yas/popup-isearch-prompt yas/no-prompt)) 2634 | 2635 | (use-package license-snippets 2636 | :load-path "/Users/blaine/emacs29.3/manual-packages/license-snippets") 2637 | (license-snippets-init) 2638 | (message "Fnished Y package configurations!!") 2639 | 2640 | 2641 | (message "Fnished package configurations!!") 2642 | (put 'downcase-region 'disabled nil) 2643 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | * Emacs 29 configuration from a README.org file. 2 | 3 | * Preface 4 | ** Status 5 | This is my current working version in mid-2024. 6 | I have yet to add headlines for all packages. 7 | This configuration is skewed toward supporting academic research tasks like bibliographic management, writing papers, and assembling grant applications in org-mode or LaTeX. 8 | 9 | ** Why use an org file to manage your Emacs configuration? 10 | 11 | The main reason is to ease the navigation of the configuration file once it becomes longer than the length of the screen in Emacs. 12 | Mine tend to be several thousand lines long. 13 | Scrolling up and down is a pain. 14 | You can collapse the file tree in org to ease navigation significantly. Enter Meta-Shift repeatedly with the cursor on the top-level headline to cycle through the folding of the headlines. 15 | You can also set up a table of contents with links to specific sites further down in the file. 16 | You could even add a backlink to the TOC. 17 | 18 | A secondary reason is to ease adding notes about using the packages and functions. 19 | These notes can include links, equations, plots, and tables. 20 | 21 | ** Why post this GitHub? 22 | - One way to render the org file into HTML. 23 | - Others can copy the code blocks of interest for their *init.el* files. 24 | - I will have a backup if my computer dies or is stolen. 25 | 26 | 27 | ** A simple approach 28 | 29 | I found a simple approach to using an org file to configure Emacs. 30 | This approach is possible now because org-mode is built into GNU Emacs. 31 | This approach was impossible several years ago when I last used an org file to manage my Emacs configuration. 32 | 33 | #+BEGIN_EXAMPLE 34 | (require 'org) 35 | (org-babel-load-file (expand-file-name "init.org" user-emacs-directory)) 36 | #+END_EXAMPLE 37 | 38 | 1. You place the above two lines of code in a *init.el* file after you have moved your existing *init.el* file to a safe place. Include nothing else. Emacs will write some lines of customization during the first boot up of Emacs. 39 | 40 | 2. Build your init.org file. 41 | - Place elisp code in org-mode source blocks. Use my elisp ~wrap-region-with-org-src-block~ function to warp marked regions of elisp in org-mode source blocks 42 | - Add org-style headlines 43 | - Move comments outside of the source blocks and uncomment them. 44 | 45 | 3. Install the *toc-org* package from MELPA. 46 | Place a TOC tag on a TOC headline. 47 | This will indicate where the headline is to go. 48 | A GitHub-compatible TOC will be generated as internal links when you reload the *init.org* file. 49 | You will not have to manually edit the TOC as you make additions or deletions. 50 | 51 | 4. If you want to post your *init.org* file on GitHub, rename it *README.org*, and it will be rendered nicely on GitHub. 52 | Bugs that prevent the rendering by Github might not prevent its use by Emacs. 53 | Some org-mode features prevent rendering on [[https://github.com/novoid/github-orgmode-tests][GitHub]]. 54 | 55 | - The ~#+TOC~ is not supported. 56 | - TODO items are not supported. 57 | - Drawers do not work. 58 | - Line breaks are often disregarded, which can affect the formatting of your text. 59 | - Features like custom LaTeX fragments, certain HTML tags, and complex table structures may not render as expected. 60 | - Elements such as ~#+BEGIN_SRC~ and ~#+BEGIN_EXAMPLE~ might not display correctly. 61 | - Code blocks with specific language syntax highlighting may not be supported. 62 | - Checkboxes, radio buttons, and interactive elements are not supported. 63 | 64 | 65 | 66 | * Table of Contents :TOC: 67 | - [[#emacs-29-configuration-from-a-readmeorg-file][Emacs 29 configuration from a README.org file.]] 68 | - [[#preface][Preface]] 69 | - [[#status][Status]] 70 | - [[#why-use-an-org-file-to-manage-your-emacs-configuration][Why use an org file to manage your Emacs configuration?]] 71 | - [[#why-post-this-github][Why post this GitHub?]] 72 | - [[#a-simple-approach][A simple approach]] 73 | - [[#package-management][Package management]] 74 | - [[#customizations][Customizations]] 75 | - [[#garbage-collection][garbage collection]] 76 | - [[#settings][Settings]] 77 | - [[#elisp-functions-by-me-and-others][Elisp functions by me and others]] 78 | - [[#shell-configuration][Shell configuration]] 79 | - [[#faked-full-screen][Faked full screen]] 80 | - [[#backups][Backups]] 81 | - [[#default-and-per-save-backups-go-here][Default and per-save backups go here:]] 82 | - [[#disable-lockfiles][Disable lockfiles.]] 83 | - [[#column-number-mode][Column number mode]] 84 | - [[#show-stray-whitespace][Show stray whitespace.]] 85 | - [[#fontlocking][Fontlocking]] 86 | - [[#show-current-time-in-modeline][Show current time in modeline]] 87 | - [[#delete-trailing-whitespaces][Delete trailing whitespaces]] 88 | - [[#display-line-numbers-need-with-s-l][Display line numbers. Need with s-l.]] 89 | - [[#hippie-expand-m-][hippie-expand M-/.]] 90 | - [[#gui-related-settings][GUI related settings]] 91 | - [[#cua-keybindings][CUA keybindings]] 92 | - [[#disable-the-c-z-sleepsuspend-key][Disable the C-z sleep/suspend key]] 93 | - [[#make-copy-and-paste-use-the-same-clipboard-as-emacs][Make copy and paste use the same clipboard as emacs.]] 94 | - [[#display-time-of-day][Display time of day]] 95 | - [[#customize-powerline][Customize powerline]] 96 | - [[#highlight-current-line][Highlight current line]] 97 | - [[#list-recently-opened-files][List recently opened files.]] 98 | - [[#utf-8][UTF-8]] 99 | - [[#quickly-access-configuration-file][Quickly access configuration file]] 100 | - [[#gui-settings][GUI settings]] 101 | - [[#global-keys][Global keys]] 102 | - [[#case-fold-search][case fold search]] 103 | - [[#show-file-path-in-title-of-buffer][Show file path in title of buffer]] 104 | - [[#browse-urls-in-text-mode][Browse URLS in text mode]] 105 | - [[#revert-buffers-when-the-underlying-file-has-changed][Revert buffers when the underlying file has changed.]] 106 | - [[#save-history-going-back-25-commands][Save history going back 25 commands.]] 107 | - [[#save-place-in-a-file][Save place in a file.]] 108 | - [[#monday-as-first-day-of-week][Monday as first day of week]] 109 | - [[#have-emacs-backups-in-a-different-directory][Have emacs backups in a different directory]] 110 | - [[#show-paren-mode][show-paren-mode]] 111 | - [[#use-y-or-n-instead-of-yes-or-no][Use y or n instead of yes or no]] 112 | - [[#system-detection][System detection]] 113 | - [[#set-keys-for-mac-os][Set keys for Mac OS]] 114 | - [[#save-the-buffer][Save the buffer.]] 115 | - [[#switch-to-previous-buffer][Switch to previous buffer]] 116 | - [[#minibuffer-history-keybindings][Minibuffer history keybindings]] 117 | - [[#bibtex-configuration][Bibtex configuration]] 118 | - [[#retina-display-of-pdfs][Retina display of PDFs]] 119 | - [[#pdf-default-page-width-behavior][PDF default page width behavior]] 120 | - [[#set-delay-in-the-matching-parenthesis-to-zero][Set delay in the matching parenthesis to zero.]] 121 | - [[#window-management][Window management]] 122 | - [[#zoom-text-in-and-out-very-sweet][Zoom text in and out. Very Sweet!]] 123 | - [[#aliases][Aliases]] 124 | - [[#a][A]] 125 | - [[#ace-window][ace-window]] 126 | - [[#auctex][auctex]] 127 | - [[#b][B]] 128 | - [[#c][C]] 129 | - [[#citar][citar]] 130 | - [[#corfu][corfu]] 131 | - [[#cape-configuration][Cape Configuration]] 132 | - [[#company-box][company-box]] 133 | - [[#company-configuration][Company Configuration]] 134 | - [[#consult][consult]] 135 | - [[#d][D]] 136 | - [[#dashboard][dashboard]] 137 | - [[#dashboard-refresh][Dashboard refresh]] 138 | - [[#e][E]] 139 | - [[#ekg][ekg]] 140 | - [[#embark][Embark]] 141 | - [[#f][F]] 142 | - [[#flycheck][flycheck]] 143 | - [[#g][G]] 144 | - [[#h][H]] 145 | - [[#hydra][hydra]] 146 | - [[#helpful][helpful]] 147 | - [[#i][I]] 148 | - [[#ivy][ivy]] 149 | - [[#ivy-rich][ivy-rich]] 150 | - [[#ivy-bibtex][ivy-bibtex]] 151 | - [[#j][J]] 152 | - [[#k][K]] 153 | - [[#kind-icon][kind-icon]] 154 | - [[#l][L]] 155 | - [[#lsp-mode][lsp-mode]] 156 | - [[#m][M]] 157 | - [[#marginalia-configuration][Marginalia Configuration]] 158 | - [[#math-preview][Math-Preview]] 159 | - [[#n][N]] 160 | - [[#orderless][orderless]] 161 | - [[#org-agenda][org-agenda]] 162 | - [[#customized-agenda-views][customized agenda views]] 163 | - [[#org-ask-location][org-ask-location]] 164 | - [[#org-capture-templates][org-capture-templates]] 165 | - [[#org-ai][org-ai]] 166 | - [[#org-babel][org-babel]] 167 | - [[#org-cc][org-cc]] 168 | - [[#org-gtd][org-gtd]] 169 | - [[#org-noter][org-noter]] 170 | - [[#org-pdftools][org-pdftools]] 171 | - [[#org-noter-pdftools][org-noter-pdftools]] 172 | - [[#org-pomodoro][org-pomodoro]] 173 | - [[#org-ref][org-ref]] 174 | - [[#org-cite-insert][org-cite-insert]] 175 | - [[#basic-org-roam-config][Basic org-roam config]] 176 | - [[#org-roam-capture-templates][org-roam-capture-templates]] 177 | - [[#toc-org][toc-org]] 178 | - [[#p][P]] 179 | - [[#s][S]] 180 | - [[#q][Q]] 181 | - [[#r][R]] 182 | - [[#s-1][S]] 183 | - [[#t][T]] 184 | - [[#treemacs][treemacs]] 185 | - [[#u][U]] 186 | - [[#v][V]] 187 | - [[#vertico-configuration][Vertico Configuration]] 188 | - [[#x][X]] 189 | - [[#w][W]] 190 | - [[#y][Y]] 191 | - [[#z][Z]] 192 | 193 | * Package management 194 | 195 | #+BEGIN_SRC emacs-lisp 196 | (require 'package) 197 | (setq package-enable-at-startup nil) 198 | (setq package-archives '(("org" . "http://orgmode.org/elpa/") 199 | ("gnu" . "http://elpa.gnu.org/packages/") 200 | ("melpa" . "http://melpa.org/packages/"))) 201 | (package-initialize) 202 | 203 | (unless (package-installed-p 'use-package) 204 | (package-refresh-contents) 205 | (package-install 'use-package)) 206 | (require 'use-package) 207 | (setq use-package-always-ensure t) 208 | 209 | 210 | (unless (package-installed-p 'quelpa) 211 | (with-temp-buffer 212 | (url-insert-file-contents "https://raw.githubusercontent.com/quelpa/quelpa/master/quelpa.el") 213 | (eval-buffer) 214 | (quelpa-self-upgrade))) 215 | 216 | (message "Finished package manger configuration.") 217 | 218 | #+END_SRC 219 | 220 | * Customizations 221 | 222 | ** garbage collection 223 | 224 | #+BEGIN_SRC emacs-lisp 225 | (use-package gcmh 226 | :diminish gcmh-mode 227 | :config 228 | (setq gcmh-idle-delay 5 229 | gcmh-high-cons-threshold (* 16 1024 1024)) ; 16mb 230 | (gcmh-mode 1)) 231 | 232 | (add-hook 'emacs-startup-hook 233 | (lambda () 234 | (setq gc-cons-percentage 0.1))) ;; Default value for `gc-cons-percentage' 235 | 236 | (add-hook 'emacs-startup-hook 237 | (lambda () 238 | (message "Emacs ready in %s with %d garbage collections." 239 | (format "%.2f seconds" 240 | (float-time 241 | (time-subtract after-init-time before-init-time))) 242 | gcs-done))) 243 | 244 | (message "Finished garbage collection.") 245 | #+END_SRC 246 | 247 | ** Settings 248 | 249 | #+BEGIN_SRC emacs-lisp 250 | (message "Start settings section.") 251 | ;;;# save current init.el to ~/.saves 252 | ;; source https://www.reddit.com/r/emacs/comments/11ap924/the_most_important_snippet_in_my_emacs_init_file/ 253 | (setq 254 | backup-by-copying t ; don't clobber symlinks 255 | backup-directory-alist 256 | '(("." . "~/.e29orgInitSaves")) ; don't litter my fs tree 257 | delete-old-versions t 258 | kept-new-versions 6 259 | kept-old-versions 2 260 | version-control t) 261 | 262 | 263 | ;; Export from org to latex 264 | (setq org-latex-pdf-process 265 | '("latexmk -pdflatex='pdflatex -interaction nonstopmode -shell-escape' -pdf -bibtex -f %f")) 266 | 267 | 268 | 269 | 270 | ;;; Basics Configuration 271 | ;;(setq openai-key "[]") 272 | ;;(setq openai-api-key "") 273 | 274 | 275 | (setq inhibit-startup-message t) ;; hide the startup message 276 | ;; (load-theme 'material t) ;; load material theme 277 | ;; (global-linum-mode t) ;; enable line numbers globally 278 | (set-default 'truncate-lines t) ;; do not wrap 279 | (prefer-coding-system 'utf-8) ;; use UTF-8 280 | 281 | ;;load prefers the newest version of a file. 282 | ;; This applies when a filename suffix is not explicitly specified and load is trying various possible suffixes (see load-suffixes and load-file-rep-suffixes). Normally, it stops at the first file that exists unless you explicitly specify one or the other. If this option is non-nil, it checks all suffixes and uses whichever file is newest. 283 | ;; (setq load-prefer-newer t) --> causes RECURSIVE LOAD error 284 | 285 | ;;;# Zoom 286 | (set-face-attribute 'default nil :height 128) 287 | 288 | ;;;# Save History 289 | (savehist-mode +1) 290 | (setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring)) 291 | 292 | 293 | ;;;# Size of the starting Window 294 | (setq initial-frame-alist '((top . 1) 295 | (left . 450) 296 | (width . 101) 297 | (height . 90))) 298 | 299 | ;;;# Line wrap 300 | (global-visual-line-mode +1) 301 | (delete-selection-mode +1) 302 | (save-place-mode +1) 303 | 304 | 305 | ;;;# set browser to open url in new tab 306 | (custom-set-variables 307 | '(browse-url-browser-function (quote browse-url-firefox)) 308 | '(browse-url-firefox-new-window-is-tab t)) 309 | 310 | (global-set-key (kbd "C-h D") 'devdocs-lookup) 311 | (message "End settings section.") 312 | #+END_SRC 313 | 314 | 315 | 316 | 317 | 318 | 319 | ** Elisp functions by me and others 320 | 321 | *** description list for LaTeX from markdown list 322 | 323 | #+BEGIN_SRC emacs-lisp 324 | (message "Begin custom elisp functions section.") 325 | ;;;### M-x description 326 | ;; Converts a selected list into a description list. 327 | ;; The elements of the list must begin with a dash. 328 | ;; The terms to be inserted into the square brackets 329 | ;; have to be added after running the function. 330 | (defun description (beg end) 331 | "wrap the active region in an 'itemize' environment, 332 | converting hyphens at the beginning of a line to \item" 333 | (interactive "r") 334 | (save-restriction 335 | (narrow-to-region beg end) 336 | (beginning-of-buffer) 337 | (insert "\\begin{description}\n") 338 | (while (re-search-forward "^- " nil t) 339 | (replace-match "\\\\item[ ]")) 340 | (end-of-buffer) 341 | (insert "\\end{description}\n"))) 342 | 343 | (message "End description function.") 344 | #+END_SRC 345 | 346 | 347 | 348 | *** enumerate list for LaTeX from markdown list 349 | 350 | #+BEGIN_SRC emacs-lisp 351 | ;;;### M-x enumerate 352 | ;; Converts a selected list into an enumerated list. 353 | ;; The elements of the list must begin with a dash. 354 | (defun enumerate (beg end) 355 | "wrap the active region in an 'itemize' environment, 356 | converting hyphens at the beginning of a line to \item" 357 | (interactive "r") 358 | (save-restriction 359 | (narrow-to-region beg end) 360 | (beginning-of-buffer) 361 | (insert "\\begin{enumerate}\n") 362 | (while (re-search-forward "^- " nil t) 363 | (replace-match "\\\\item ")) 364 | (end-of-buffer) 365 | (insert "\\end{enumerate}\n"))) 366 | 367 | (message "End enumerate function.") 368 | #+END_SRC 369 | 370 | 371 | *** itemized list for LateX from markdown list 372 | 373 | Converts a selected markdown list into an itemized list. 374 | The elements of the list must begin with a dash. 375 | 376 | #+BEGIN_SRC emacs-lisp 377 | (message "Begin itemize.") 378 | (defun itemize (beg end) 379 | "wrap the active region in an itemize environment, 380 | converting hyphens at the beginning of a line to blackslash item" 381 | (interactive "r") 382 | (save-restriction 383 | (narrow-to-region beg end) 384 | (beginning-of-buffer) 385 | (insert "\\begin{itemize}\n") 386 | (while (re-search-forward "^- " nil t) 387 | (replace-match "\\\\item ")) 388 | (end-of-buffer) 389 | (insert "\\end{itemize}\n"))) 390 | (message "End itemize function.") 391 | #+END_SRC 392 | 393 | 394 | *** Checkmark, insert 395 | 396 | #+BEGIN_SRC emacs-lisp 397 | (defun ichmk () 398 | "Inserts a checkmark." 399 | (interactive) 400 | (insert "\\\item \\checkmark ")) 401 | (message "End checkmark function.") 402 | #+END_SRC 403 | 404 | 405 | *** Convert org headlines to beamer slides 406 | #+BEGIN_SRC emacs-lisp 407 | (defun org-to-beamer-slides-in-region (start end) 408 | "Convert an Org-mode outline as a list of headlines into Beamer slides flanked by unnumbered subsections and notes. The output can be pasted into a beam slideshow on Overleaf." 409 | (interactive "r") 410 | (save-restriction 411 | (narrow-to-region start end) 412 | (goto-char (point-min)) 413 | (while (re-search-forward "^\\*+ \\(.*\\)$" nil t) 414 | (let ((title (match-string 1))) 415 | (replace-match (concat "\\\\subsection*{" title "}\n\\\\begin{frame}\n\\\\frametitle{" title "}\n") nil nil) 416 | (end-of-line) 417 | (insert "\n\\end{frame}\n\\note{Your note here}\n\n")))) 418 | (message "Conversion to Beamer slides complete!")) 419 | #+END_SRC 420 | 421 | 422 | *** Unwrap paragraphs into one sentence per line 423 | 424 | https://stackoverflow.com/questions/539984/how-do-i-get-emacs-to-fill-sentences-but-not-paragraphs/6103404\#6103404 425 | Unwrap paragraphs into one sentence per line. 426 | #+BEGIN_SRC emacs-lisp 427 | (defun fill-sentences-in-paragraph () 428 | "Put a newline at the end of each sentence in paragraph." 429 | (interactive) 430 | (save-excursion 431 | (mark-paragraph) 432 | (call-interactively 'fill-sentences-in-region))) 433 | #+END_SRC 434 | 435 | 436 | *** One line per sentence 437 | 438 | #+BEGIN_SRC emacs-lisp 439 | (defun fill-sentences-in-region (start end) 440 | "Put a newline at the end of each sentence in region." 441 | (interactive "*r") 442 | (call-interactively 'unfill-region) 443 | (save-excursion 444 | (goto-char start) 445 | (while (re-search-forward "[.?!][]\"')}]*\\( \\)" end t) 446 | (newline-and-indent)))) 447 | #+END_SRC 448 | 449 | 450 | *** Read my-openai-api-key 451 | 452 | #+BEGIN_SRC emacs-lisp 453 | (defun my-openai-api-key () 454 | "Read api key from disk." 455 | (with-temp-buffer 456 | (insert-file-contents "~/openaikey.txt") 457 | (string-trim (buffer-string)))) 458 | #+END_SRC 459 | 460 | 461 | *** Unfill region 462 | 463 | #+BEGIN_SRC emacs-lisp 464 | (defun unfill-region (beg end) 465 | "Unfill the region, joining text paragraphs into a 466 | single logical line. This is useful, e.g., for use 467 | with 'visual-line-mode'." 468 | (interactive "*r") 469 | (let ((fill-column (point-max))) 470 | (fill-region beg end))) 471 | 472 | (global-set-key "\M-q" 'fill-sentences-in-paragraph) 473 | #+END_SRC 474 | 475 | *** reload-init 476 | Inspried https://sachachua.com/dotemacs/index.html#org4dd39d0 477 | 478 | #+BEGIN_SRC emacs-lisp 479 | (defun reload-init-e29org () 480 | "Reload my init.el file. Edit the path to suite your needs." 481 | (interactive) 482 | (load-file "~/e29org/init.el")) 483 | #+END_SRC 484 | 485 | 486 | *** reload-hydras 487 | 488 | #+BEGIN_SRC emacs-lisp 489 | (message "Begin the hydra reload commands.") 490 | (defun reload-hydras () 491 | "Reload my-hydras.el. Edit the path to suite your needs." 492 | (interactive) 493 | (load-file "~/emacs29.3/my-hydras/my-hydras.el")) 494 | #+END_SRC 495 | 496 | 497 | *** reload-learning-spiral-hydras 498 | 499 | #+BEGIN_SRC emacs-lisp 500 | (defun reload-learning-spiral-hydras () 501 | "Reload learning-spiral-hydras.el. Edit the path to suite your needs." 502 | (interactive) 503 | (load-file "~/emacs29.3/my-hydras/learning-spiral-hydras.el")) 504 | #+END_SRC 505 | 506 | 507 | *** reload-writing-projects-hydra 508 | 509 | #+BEGIN_SRC emacs-lisp 510 | (defun reload-writing-projects-hydra () 511 | "Reload lwriting-projects-hdyra.el. Edit the path to suite your needs." 512 | (interactive) 513 | (load-file "~/emacs29.3/my-hydras/writing-projects-hydra.el")) 514 | #+END_SRC 515 | 516 | 517 | *** reload-talon-quiz-hydras 518 | 519 | #+BEGIN_SRC emacs-lisp 520 | (defun reload-talon-quiz-hydras () 521 | "Reload learning-spiral-hydras.el. Edit the path to suite your needs." 522 | (interactive) 523 | (load-file "~/emacs29.3/my-hydras/talon-quiz-hydras.el")) 524 | #+END_SRC 525 | 526 | 527 | *** reload-uniteai 528 | 529 | #+BEGIN_SRC emacs-lisp 530 | (defun reload-uniteai () 531 | "Reload my-uniteai.el. Edit the path to suite your needs." 532 | (interactive) 533 | (load-file "~/e29org/my-uniteai.el")) 534 | #+END_SRC 535 | 536 | *** Clean and sort list of items in region 537 | 538 | #+BEGIN_SRC emacs-lisp 539 | (defun clean-sort-list-in-region (beg end) 540 | "Clean and sort the lines in the selected region. 541 | Removes duplicate lines, blank lines, and sort alphabetically. 542 | Built by Copilot" 543 | (interactive "r") 544 | (let ((lines (split-string (buffer-substring-no-properties beg end) "\n" t)) 545 | (cleaned-lines nil)) 546 | ;; Remove duplicates and blank lines 547 | (dolist (line lines) 548 | (when (and (not (string-blank-p line)) 549 | (not (member line cleaned-lines))) 550 | (push line cleaned-lines))) 551 | ;; Sort alphabetically 552 | (setq cleaned-lines (sort cleaned-lines #'string<)) 553 | ;; Replace the region with the cleaned and sorted lines 554 | (delete-region beg end) 555 | (insert (mapconcat #'identity cleaned-lines "\n")))) 556 | (global-set-key (kbd "C-c s") 'clean-sort-list-in-region) 557 | #+END_SRC 558 | 559 | *** Word counts on regions 560 | 561 | Source https://emacs.stackexchange.com/questions/12938/how-can-i-evaluate-elisp-in-an-orgmode-file-when-it-is-opened 562 | I use this to invoke wc-mode in manuscript documents. 563 | 564 | #+BEGIN_SRC emacs-lisp 565 | (defun tdh/eval-startblock () 566 | (if (member "startblock" (org-babel-src-block-names)) 567 | (save-excursion 568 | (org-babel-goto-named-src-block "startblock") 569 | (org-babel-execute-src-block)) 570 | nil 571 | ) 572 | ) 573 | (add-hook 'org-mode-hook 'tdh/eval-startblock) 574 | 575 | ;; source https://irreal.org/blog/?p=5722 576 | ;; works on regions well 577 | (defun my/count-words-in-subtree-or-region () 578 | ;; Bind this to a key in org-mode, e.g. C-= 579 | (interactive) 580 | (call-interactively (if (region-active-p) 581 | 'count-words-region 582 | 'my/count-words-in-subtree))) 583 | 584 | (defun my/count-words-in-subtree () 585 | "Count words in current node and child nodes, excluding heading text." 586 | (interactive) 587 | (org-with-wide-buffer 588 | (message "%s words in subtree" 589 | (-sum (org-map-entries 590 | (lambda () 591 | (outline-back-to-heading) 592 | (forward-line 1) 593 | (while (or (looking-at org-keyword-time-regexp) 594 | (org-in-drawer-p)) 595 | (forward-line 1)) 596 | (count-words (point) 597 | (progn 598 | (outline-end-of-subtree) 599 | (point)))) 600 | nil 'tree))))) 601 | #+END_SRC 602 | 603 | 604 | 605 | *** open PDFs with default system viewer (usually Preview on a Mac) 606 | Source: http://stackoverflow.com/a/1253761/1325477https://emacs.stackexchange.com/questions/3105/how-to-use-an-external-program-as-the-default-way-to-open-pdfs-from-emacs 607 | Remove "\\.pdf" to enable use of PDF tools 608 | 609 | #+BEGIN_SRC emacs-lisp 610 | (defun mac-open (filename) 611 | (interactive "fFilename: ") 612 | (let ((process-connection-type)) 613 | (start-process "" nil "open" (expand-file-name filename)))) 614 | 615 | (defun find-file-auto (orig-fun &rest args) 616 | (let ((filename (car args))) 617 | (if (cl-find-if 618 | (lambda (regexp) (string-match regexp filename)) 619 | '( "\\.doc\\'" "\\.docx?\\'" "\\.xlsx?\\'" "\\.xlsm?\\'" "\\.pptx?\\'" "\\.itmz\\'" "\\.png\\'")) 620 | (mac-open filename) 621 | (apply orig-fun args)))) 622 | 623 | (advice-add 'find-file :around 'find-file-auto) 624 | #+END_SRC 625 | 626 | 627 | *** orglog 628 | 629 | Copy template writing log, rename the file with the project ID included in the filename, and open the file in a new buffer. 630 | Translated the corresponding bash function with copilot. 631 | 632 | #+BEGIN_SRC emacs-lisp 633 | (defun orglog (projectID) 634 | "Copy template writing log in org with project number in title and open the file." 635 | (interactive "sProject ID: ") 636 | (if (or (string= projectID "") 637 | (string-match-p " " projectID)) 638 | (progn 639 | (message "Usage: orglog projectID") 640 | (error "Invalid number of arguments")) 641 | (let ((template "~/6112MooersLabGitHubLabRepos/writingLogTemplateInOrg/writingLogTemplateVer7.org") 642 | (destination (concat "log" projectID ".org"))) 643 | (copy-file template destination t) 644 | (find-file destination) 645 | (message "Write writing log to %s file and open in a new buffer." destination)))) 646 | #+END_SRC 647 | 648 | 649 | *** TOC generation for org-file 650 | 651 | Run this function to generate a TOC for an org-file. 652 | The items in the TOC will be hyperlinked to the headlines in the body of the org file. 653 | 654 | #+BEGIN_SRC emacs-lisp 655 | (defun org-generate-toc () 656 | "Generate a table of contents for the current Org-mode buffer." 657 | (interactive) 658 | (let ((toc-buffer (get-buffer-create "*Org TOC*")) 659 | (toc-entries '())) 660 | (save-excursion 661 | (goto-char (point-min)) 662 | (while (re-search-forward org-heading-regexp nil t) 663 | (let ((level (org-current-level)) 664 | (headline (match-string-no-properties 0)) 665 | (link (org-make-link-string (concat "" (org-get-heading t t t t))))) 666 | (push (concat (make-string level ?*) " " link) toc-entries)))) 667 | (with-current-buffer toc-buffer 668 | (erase-buffer) 669 | (insert "#+TOC: headlines\n") 670 | (dolist (entry (nreverse toc-entries)) 671 | (insert entry "\n"))) 672 | (switch-to-buffer-other-window toc-buffer) 673 | (org-mode))) 674 | 675 | (global-set-key (kbd "C-c t") 'org-generate-toc) 676 | #+END_SRC 677 | 678 | 679 | *** Wrap code blocks in org-mode source block 680 | 681 | Wrap a marked block of elisp code with a org-mode source block. 682 | I need to make a varient for LaTeX minted code environment. 683 | 684 | #+BEGIN_SRC emacs-lisp 685 | (defun wrap-region-with-org-src-block () 686 | "Wrap the selected region with an elisp source block." 687 | (interactive) 688 | (let ((begin (region-beginning)) 689 | (end (region-end))) 690 | (goto-char end) 691 | (insert "\n#+END_SRC") 692 | (goto-char begin) 693 | (insert "#+BEGIN_SRC emacs-lisp\n"))) 694 | 695 | (global-set-key (kbd "C-c w") 'wrap-region-with-org-src-block) 696 | #+END_SRC 697 | 698 | ** create-latex-table-with-caption 699 | 700 | This interactive function prompts the user for the number of rows, columns, caption, and label. 701 | Then this function generates a table that has a top Rule and a rule below the column labels. 702 | It also has a bottom rule. It does not contain any vertical rules. 703 | This function required five rounds of iteration with Copilot. 704 | It was developed after developing the function below: create-org-table-with-caption. 705 | That code was used as a template for Copilot. 706 | It in turn had been developed after four or five rounds of iteration. 707 | 708 | 709 | #+BEGIN_SRC emacs-lisp 710 | (defun create-latex-table-with-caption () 711 | (interactive) 712 | (let ((rows (read-number "Enter the number of rows: ")) 713 | (cols (read-number "Enter the number of columns: ")) 714 | (caption (read-string "Enter the table's caption: ")) 715 | (label (read-string "Enter the table's label: "))) 716 | (insert (format "\\begin{table}[h]\n\\centering\n\\caption{%s \\label{%s}}\n\\begin{tabular}{%s}\n\\hline\n" 717 | caption label (make-string cols ?c))) 718 | ;; Insert column labels 719 | (dotimes (col cols) 720 | (insert (format " %c " (+ ?A col))) 721 | (if (< col (1- cols)) 722 | (insert "&"))) 723 | (insert " \\\\\n\\hline\n") 724 | ;; Insert table rows 725 | (dotimes (_ rows) 726 | (dotimes (col cols) 727 | (insert (format " Cell %d-%d " (1+ col) (1+ _))) 728 | (if (< col (1- cols)) 729 | (insert "&"))) 730 | (insert " \\\\\n")) 731 | (insert "\\hline\n\\end{tabular}\n\\end{table}\n"))) 732 | #+END_SRC 733 | 734 | 735 | 736 | 737 | ** create-org-table-with-caption 738 | 739 | This interactive function prompts the user for the number of rows. columns, and the caption of the table. 740 | 741 | 742 | #+BEGIN_SRC emacs-lisp 743 | (defun create-org-table-with-caption () 744 | "This interactive function prompts the user for the number of rows. columns, and the caption of the table." 745 | (interactive) 746 | (let ((rows (read-number "Enter the number of rows: ")) 747 | (cols (read-number "Enter the number of columns: ")) 748 | (label (read-string "Enter the table label: ")) 749 | (caption (read-string "Enter the table's caption: "))) 750 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 751 | (insert (format "#+NAME: %s\n" label)) 752 | (insert "|") 753 | (dotimes (_ cols) 754 | (insert "----+")) 755 | (insert "\n|") 756 | ;;(insert "|") 757 | (dotimes (col cols) 758 | (insert (format " %c |" (+ ?A col)))) 759 | (insert "\n|") 760 | (dotimes (_ cols) 761 | (insert "----+")) 762 | (insert "\n") 763 | (dotimes (_ rows) 764 | (insert "|") 765 | (dotimes (_ cols) 766 | (insert " |")) 767 | (insert "\n")) 768 | (insert "|") 769 | (dotimes (_ cols) 770 | (insert "----+")))) 771 | #+END_SRC 772 | 773 | *** insert-org-captioned-figure 774 | 775 | The function prompts the user for the image file path and name, the label, and the caption. 776 | 777 | #+BEGIN_SRC emacs-lisp 778 | (defun insert-org-captioned-figure () 779 | "Insert a captioned figure in Org-mode." 780 | (interactive) 781 | (let ((image-name (read-string "Enter the image file path: ")) 782 | (label (read-string "Enter the figure label: ")) 783 | (caption (read-string "Enter the figure caption: "))) 784 | (insert (format "#+CAPTION: %s \\label{%s}\n" caption label)) 785 | (insert (format "#+NAME: %s\n" label)) 786 | (insert (format "[[file:%s]]\n" image-name)))) 787 | #+END_SRC 788 | 789 | 790 | #+BEGIN_SRC emacs-lisp 791 | (message "End of the custom elisp functions section.") 792 | #+END_SRC 793 | 794 | 795 | 796 | 797 | ** Shell configuration 798 | 799 | #+BEGIN_SRC emacs-lisp 800 | (use-package exec-path-from-shell 801 | :init 802 | (setenv "SHELL" "/opt/local/bin/bash") 803 | :if (memq window-system '(mac ns x)) 804 | :config 805 | (setq exec-path-from-shell-variables '("PATH" "GOPATH" "PYTHONPATH")) 806 | (exec-path-from-shell-initialize)) 807 | (message "Finished shell configuration. Line 480.") 808 | 809 | 810 | ;;;# Size of the starting Window 811 | (setq initial-frame-alist '((top . 1) 812 | (left . 450) 813 | (width . 101) 814 | (height . 90))) 815 | #+END_SRC 816 | 817 | 818 | ** Faked full screen 819 | #+BEGIN_SRC emacs-lisp 820 | (use-package maxframe) 821 | (defvar my-fullscreen-p t "Check if fullscreen is on or off") 822 | (defun my-toggle-fullscreen () 823 | (interactive) 824 | (setq my-fullscreen-p (not my-fullscreen-p)) 825 | (if my-fullscreen-p 826 | (restore-frame) 827 | (maximize-frame))) 828 | (global-set-key (kbd "M-S") 'toggle-frame-fullscreen) ;; conflicts with an auctex command to insert an \item in a list. 829 | (message "Finished frame configuration.") 830 | #+END_SRC 831 | 832 | ** Backups 833 | #+BEGIN_SRC emacs-lisp 834 | (setq vc-make-backup-files t) 835 | 836 | (setq version-control t ;; Use version numbers for backups. 837 | kept-new-versions 10 ;; Number of newest versions to keep. 838 | kept-old-versions 0 ;; Number of oldest versions to keep. 839 | delete-old-versions t ;; Don't ask to delete excess backup versions. 840 | backup-by-copying t) ;; Copy all files, don't rename them. 841 | 842 | #+END_SRC 843 | 844 | If you want to avoid 'backup-by-copying', you can instead use ~(setq backup-by-copying-when-linked t)~. 845 | 846 | but that makes the second, "per save" backup below not run, since 847 | buffers with no backing file on disk are not backed up, and 848 | renaming removes the backing file. The "per session" backup will 849 | happen in any case, you'll just have less consistent numbering of 850 | per-save backups (i.e. only the second and subsequent save will 851 | result in per-save backups). 852 | 853 | If you want to avoid backing up some files, e.g. large files, 854 | then try setting 'backup-enable-predicate'. You'll want to 855 | extend 'normal-backup-enable-predicate', which already avoids 856 | things like backing up files in '/tmp'. 857 | 858 | ** Default and per-save backups go here: 859 | 860 | #+BEGIN_SRC emacs-lisp 861 | (setq backup-directory-alist '(("" . "~/e29org/backup/per-save"))) 862 | 863 | (defun force-backup-of-buffer () 864 | ;; Make a special "per session" backup at the first save of each 865 | ;; emacs session. 866 | (when (not buffer-backed-up) 867 | ;; Override the default parameters for per-session backups. 868 | (let ((backup-directory-alist '(("" . "~/e29org/backup/per-session"))) 869 | (kept-new-versions 3)) 870 | (backup-buffer))) 871 | ;; Make a "per save" backup on each save. The first save results in 872 | ;; both a per-session and a per-save backup, to keep the numbering 873 | ;; of per-save backups consistent. 874 | (let ((buffer-backed-up nil)) 875 | (backup-buffer))) 876 | (add-hook 'before-save-hook 'force-backup-of-buffer) 877 | (message "Finished force-backup-of-buffer configuration. Line 537.") 878 | 879 | ;;;# Do not move the current file while creating backup. 880 | (setq backup-by-copying t) 881 | (message "Backup configuration finished. Line 541.") 882 | #+END_SRC 883 | 884 | ** Disable lockfiles. 885 | 886 | #+BEGIN_SRC emacs-lisp 887 | (setq create-lockfiles nil) 888 | #+END_SRC 889 | 890 | ** Column number mode 891 | 892 | #+BEGIN_SRC emacs-lisp 893 | (column-number-mode) 894 | #+END_SRC 895 | 896 | 897 | ** Show stray whitespace. 898 | #+BEGIN_SRC emacs-lisp 899 | (setq-default show-trailing-whitespace t) 900 | (setq-default indicate-empty-lines t) 901 | (setq-default indicate-buffer-boundaries 'left) 902 | 903 | ;;; Add a newline automatically at the end of a file while saving. 904 | (setq-default require-final-newline t) 905 | 906 | ;;; A single space follows the end of sentence. 907 | (setq sentence-end-double-space nil) 908 | #+END_SRC 909 | 910 | ** Fontlocking 911 | This is the term of syntax highlighting in Emacs. 912 | 913 | #+BEGIN_SRC emacs-lisp 914 | ;; (global-set-key (kbd "C-c p") 'dpkg-menpdf 915 | 916 | ;;;# Turn on font-locking or syntax highlighting 917 | (global-font-lock-mode t) 918 | 919 | ;;;# font size in the modeline 920 | (set-face-attribute 'mode-line nil :height 140) 921 | 922 | 923 | ;;;# set default coding of buffers 924 | (setq default-buffer-file-coding-system 'utf-8-unix) 925 | 926 | ;; Switch from tabs to spaces for indentation 927 | ;; Set the indentation level to 4. 928 | (setq-default indent-tabs-mode nil) 929 | (setq-default tab-width 4) 930 | 931 | ;;;# Indentation setting for various languages. 932 | (setq c-basic-offset 4) 933 | (setq js-indent-level 2) 934 | (setq css-indent-offset 2) 935 | (setq python-basic-offset 4) 936 | 937 | (setq user-init-file "/Users/blaine/e29org/init.el") 938 | (setq user-emacs-directory "/Users/blaine/e29org/") 939 | ;; (setq default-directory "/Users/blaine") 940 | ;; the directory that you start Emacs in should be the default for the current buffer 941 | (setenv "HOME" "/Users/blaine") 942 | ;; (load user-init-file) 943 | 944 | 945 | (advice-add 'describe-function-1 :after #'elisp-demos-advice-describe-function-1) 946 | 947 | (advice-add 'helpful-update :after #'elisp-demos-advice-helpful-update) 948 | 949 | ;;;# Write customizations to a separate file instead of this file. 950 | (setq custom-file (expand-file-name "custom.el" user-emacs-directory)) 951 | (load custom-file t) 952 | #+END_SRC 953 | 954 | 955 | 956 | 957 | ** Show current time in modeline 958 | #+BEGIN_SRC emacs-lisp 959 | (defun show-current-time () 960 | "Show current time." 961 | (interactive) 962 | (message (current-time-string))) 963 | #+END_SRC 964 | 965 | ** Delete trailing whitespaces 966 | #+BEGIN_SRC emacs-lisp 967 | (global-set-key (kbd "C-c d") 'delete-trailing-whitespace) 968 | #+END_SRC 969 | 970 | 971 | ** Display line numbers. Need with s-l. 972 | #+BEGIN_SRC emacs-lisp 973 | (global-display-line-numbers-mode) 974 | #+END_SRC 975 | 976 | ** hippie-expand M-/. 977 | Seems to be comflicting with Corfu, Cape, and dabrrev. 978 | 979 | #+BEGIN_SRC emacs-lisp 980 | ;; (global-set-key [remap dabbrev-expand] 'hippie-expand) 981 | #+END_SRC 982 | 983 | 984 | ** GUI related settings 985 | #+BEGIN_SRC emacs-lisp 986 | (if (display-graphic-p) 987 | (progn 988 | ;; Removed some UI elements 989 | ;; (menu-bar-mode -1) 990 | (tool-bar-mode -1) 991 | (scroll-bar-mode -1) 992 | ;; Show battery status 993 | (display-battery-mode 1))) 994 | #+END_SRC 995 | 996 | 997 | ** CUA keybindings 998 | 999 | #+BEGIN_SRC emacs-lisp 1000 | ;; Hey, stop being a whimp and learn the Emacs keybindings! 1001 | ;; ;; Set copy+paste 1002 | ;; (cua-mode t) 1003 | ;; (setq cua-auto-tabify-rectangles nil) ;; Don't tabify after rectangle commands 1004 | ;; (transient-mark-mode 1) ;; No region when it is not highlighted 1005 | ;; (setq cua-keep-region-after-copy t) ;; Standard Windows behaviour 1006 | 1007 | ;; REMOVE THE SCRATCH BUFFER AT STARTUP 1008 | ;; Makes *scratch* empty. 1009 | ;; (setq initial-scratch-message "") 1010 | ;; Removes *scratch* from buffer after the mode has been set. 1011 | ;; (defun remove-scratch-buffer () 1012 | ;; (if (get-buffer "*scratch*") 1013 | ;; (kill-buffer "*scratch*"))) 1014 | ;; (add-hook 'after-change-major-mode-hook 'remove-scratch-buffer) 1015 | #+END_SRC 1016 | 1017 | 1018 | ** Disable the C-z sleep/suspend key 1019 | See http://stackoverflow.com/questions/28202546/hitting-ctrl-z-in-emacs-freezes-everything 1020 | 1021 | #+BEGIN_SRC emacs-lisp 1022 | (global-unset-key (kbd "C-z")) 1023 | #+END_SRC 1024 | 1025 | 1026 | 1027 | ** Make copy and paste use the same clipboard as emacs. 1028 | 1029 | #+BEGIN_SRC emacs-lisp 1030 | (setq select-enable-primary t 1031 | select-enable-clipboard t) 1032 | #+END_SRC 1033 | 1034 | ** Display time of day 1035 | 1036 | #+BEGIN_SRC emacs-lisp 1037 | (setq display-time-default-load-average nil) 1038 | (setq display-time-day-and-date t display-time-24hr-format t) 1039 | (display-time-mode t) 1040 | #+END_SRC 1041 | 1042 | 1043 | ;;;# dired-icon-mode 1044 | (use-package dired-icon 1045 | :ensure t 1046 | :config 1047 | (add-hook 'dired-mode-hook 'dired-icon-mode)) 1048 | 1049 | 1050 | ;; Revert Dired and other buffers after changes to files in directories on disk. 1051 | ;; Source: [[https://www.youtube.com/watch?v=51eSeqcaikM&list=PLEoMzSkcN8oNmd98m_6FoaJseUsa6QGm2&index=2][Dave Wilson]] 1052 | (setq global-auto-revert-non-file-buffers t) 1053 | 1054 | 1055 | ** Customize powerline 1056 | 1057 | The line above the command line at the bottom of the screen. 1058 | #+BEGIN_SRC emacs-lisp 1059 | (use-package powerline) 1060 | (powerline-default-theme) 1061 | #+END_SRC 1062 | 1063 | 1064 | ** Highlight current line 1065 | #+BEGIN_SRC emacs-lisp 1066 | (global-hl-line-mode +1) 1067 | (set-face-background hl-line-face "wheat1") 1068 | (set-face-attribute 'mode-line nil :height 180) 1069 | #+END_SRC 1070 | 1071 | ** List recently opened files. 1072 | 1073 | #+BEGIN_SRC emacs-lisp 1074 | (recentf-mode 1) 1075 | (global-set-key "\C-x\ \C-r" 'recentf-open-files) 1076 | #+END_SRC 1077 | 1078 | ** UTF-8 1079 | 1080 | #+BEGIN_SRC emacs-lisp 1081 | (set-language-environment "UTF-8") 1082 | (set-default-coding-systems 'utf-8) 1083 | (set-keyboard-coding-system 'utf-8-unix) 1084 | (set-terminal-coding-system 'utf-8-unix) 1085 | #+END_SRC 1086 | 1087 | 1088 | 1089 | ** Quickly access configuration file 1090 | #+BEGIN_SRC emacs-lisp 1091 | (global-set-key (kbd "C-c e") 1092 | (lambda() 1093 | (interactive) 1094 | (find-file "~/e29org/README.org"))) 1095 | #+END_SRC 1096 | 1097 | 1098 | ** GUI settings 1099 | 1100 | #+BEGIN_SRC emacs-lisp 1101 | (set-face-attribute 'default nil :height 140) 1102 | 1103 | (set-frame-parameter (selected-frame) 'buffer-predicate 1104 | (lambda (buf) 1105 | (let ((name (buffer-name buf))) 1106 | (not (or (string-prefix-p "*" name) 1107 | (eq 'dired-mode (buffer-local-value 'major-mode buf))))))) 1108 | #+END_SRC 1109 | 1110 | ** Global keys 1111 | If you use a window manager be careful of possible key binding clashes 1112 | 1113 | #+BEGIN_SRC emacs-lisp 1114 | (setq recenter-positions '(top middle bottom)) 1115 | (global-set-key (kbd "C-1") 'kill-this-buffer) 1116 | (global-set-key (kbd "C-") (kbd "C-u 1 C-v")) 1117 | (global-set-key (kbd "C-") (kbd "C-u 1 M-v")) 1118 | (global-set-key [C-tab] 'other-window) 1119 | (global-set-key (kbd "C-c c") 'calendar) 1120 | (global-set-key (kbd "C-x C-b") 'ibuffer) 1121 | (global-set-key (kbd "C-`") 'mode-line-other-buffer) 1122 | ;; (global-set-key (kbd "M-/") #'hippie-expand) 1123 | (global-set-key (kbd "C-x C-j") 'dired-jump) 1124 | (global-set-key (kbd "C-c r") 'remember) 1125 | #+END_SRC 1126 | 1127 | 1128 | ** case fold search 1129 | 1130 | #+BEGIN_SRC emacs-lisp 1131 | (setq case-fold-search t) 1132 | #+END_SRC 1133 | 1134 | 1135 | ** Show file path in title of buffer 1136 | 1137 | Show the file path in the title of the frame. 1138 | Source https://stackoverflow.com/questions/2903426/display-path-of-file-in-status-bar See entry by mortnene 1139 | This is much more useful than just showing the file name or buffer name in the frame title. 1140 | 1141 | 1142 | #+BEGIN_SRC emacs-lisp 1143 | (setq frame-title-format 1144 | '(:eval 1145 | (if buffer-file-name 1146 | (replace-regexp-in-string 1147 | "\\\\" "/" 1148 | (replace-regexp-in-string 1149 | (regexp-quote (getenv "HOME")) "e30: ~" 1150 | (convert-standard-filename buffer-file-name))) 1151 | (buffer-name)))) 1152 | 1153 | ; ;; Source https://stackoverflow.com/questions/50222656/setting-emacs-frame-title-in-emacs 1154 | ; (setq frame-title-format 1155 | ; (concat "%b - emacs@" (system-name))) 1156 | ; (setq-default frame-title-format '("%f [%m]")) 1157 | ; (setq frame-title-format "Main emacs29.3 config - %b " ) 1158 | #+END_SRC 1159 | 1160 | 1161 | 1162 | ** Browse URLS in text mode 1163 | #+BEGIN_SRC emacs-lisp 1164 | (global-goto-address-mode +1) 1165 | #+END_SRC 1166 | 1167 | 1168 | ** Revert buffers when the underlying file has changed. 1169 | #+BEGIN_SRC emacs-lisp 1170 | (global-auto-revert-mode 1) 1171 | #+END_SRC 1172 | 1173 | 1174 | ** Save history going back 25 commands. 1175 | Use M-p to get previous command used in the minibuffer. 1176 | Use M-n to move to next command. 1177 | 1178 | #+BEGIN_SRC emacs-lisp 1179 | (setq history-length 25) 1180 | (savehist-mode 1) 1181 | #+END_SRC 1182 | 1183 | 1184 | ** Save place in a file. 1185 | #+BEGIN_SRC emacs-lisp 1186 | (save-place-mode 1) 1187 | #+END_SRC 1188 | 1189 | 1190 | ** Monday as first day of week 1191 | Sets monday to be the first day of the week in calendar 1192 | #+BEGIN_SRC emacs-lisp 1193 | (setq calendar-week-start-day 1) 1194 | #+END_SRC 1195 | 1196 | ** Have emacs backups in a different directory 1197 | #+BEGIN_SRC emacs-lisp 1198 | ;; (some build-systems build automatically all files with a prefix, and .#something.someending breakes that) 1199 | (setq backup-directory-alist '(("." . "~/.emacsbackups"))) 1200 | #+END_SRC 1201 | 1202 | 1203 | ** show-paren-mode 1204 | Enable show-paren-mode to visualize paranthesis and make it possible to delete things we have marked. 1205 | 1206 | #+BEGIN_SRC emacs-lisp 1207 | (show-paren-mode 1) 1208 | (delete-selection-mode 1) 1209 | #+END_SRC 1210 | 1211 | 1212 | ** Use y or n instead of yes or no 1213 | 1214 | #+BEGIN_SRC emacs-lisp 1215 | (defalias 'yes-or-no-p 'y-or-n-p) 1216 | #+END_SRC 1217 | 1218 | ** System detection 1219 | 1220 | These settings enables using the same configuration file on multiple platforms. 1221 | Note that windows-nt includes [[https://www.gnu.org/software/emacs/manual/html_node/elisp/System-Environment.html][windows 10]]. 1222 | 1223 | #+BEGIN_SRC emacs-lisp 1224 | (defconst *is-a-mac* (eq system-type 'darwin)) 1225 | (defconst *is-a-linux* (eq system-type 'gnu/linux)) 1226 | (defconst *is-windows* (eq system-type 'windows-nt)) 1227 | (defconst *is-cygwin* (eq system-type 'cygwin)) 1228 | (defconst *is-unix* (not *is-windows*)) 1229 | #+END_SRC 1230 | 1231 | 1232 | ** Set keys for Mac OS 1233 | See this [[http://ergoemacs.org/emacs/emacs_hyper_super_keys.html][ for more information.]] 1234 | Set keys for Apple keyboard, for emacs in OS X. 1235 | Source http://xahlee.info/emacs/emacs/emacs_hyper_super_keys.html. 1236 | 1237 | #+BEGIN_SRC emacs-lisp 1238 | (setq mac-command-modifier 'meta) ; make cmd key do Meta 1239 | (setq mac-option-modifier 'super) ; make option key do Super. 1240 | (setq mac-control-modifier 'control) ; make Control key do Control 1241 | (setq mac-function-modifier 'hyper) ; make Fn key do Hyper. Only works on Apple produced keyboards. 1242 | (setq mac-right-command-modifier 'hyper) 1243 | #+END_SRC 1244 | 1245 | 1246 | 1247 | ** Save the buffer. 1248 | Should use C-x C-s 1249 | #+BEGIN_SRC emacs-lisp 1250 | (define-key global-map (kbd "s-s") 'save-buffer) 1251 | #+END_SRC 1252 | 1253 | ** Switch to previous buffer 1254 | 1255 | #+BEGIN_SRC emacs-lisp 1256 | (define-key global-map (kbd "H-") 'previous-buffer) 1257 | ;;;# Switch to next buffer 1258 | (define-key global-map (kbd "H-") 'next-buffer) 1259 | #+END_SRC 1260 | 1261 | ** Minibuffer history keybindings 1262 | The calling up of a previously issued command in the minibuffer with ~M-p~ saves times. 1263 | 1264 | #+BEGIN_SRC emacs-lisp 1265 | (autoload 'edit-server-maybe-dehtmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 1266 | (autoload 'edit-server-maybe-htmlize-buffer "edit-server-htmlize" "edit-server-htmlize" t) 1267 | (add-hook 'edit-server-start-hook 'edit-server-maybe-dehtmlize-buffer) 1268 | (add-hook 'edit-server-done-hook 'edit-server-maybe-htmlize-buffer) 1269 | (define-key minibuffer-local-map (kbd "M-p") 'previous-complete-history-element) 1270 | (define-key minibuffer-local-map (kbd "M-n") 'next-complete-history-element) 1271 | (define-key minibuffer-local-map (kbd "") 'previous-complete-history-element) 1272 | (define-key minibuffer-local-map (kbd "") 'next-complete-history-element) 1273 | 1274 | ;;;# switch-to-minibuffer 1275 | (defun switch-to-minibuffer () 1276 | "Switch to minibuffer window." 1277 | (interactive) 1278 | (if (active-minibuffer-window) 1279 | (select-window (active-minibuffer-window)) 1280 | (error "Minibuffer is not active"))) 1281 | 1282 | (global-set-key "\C-cm" 'switch-to-minibuffer) ;; Bind to `C-c m' for minibuffer. 1283 | #+END_SRC 1284 | 1285 | 1286 | ** Bibtex configuration 1287 | #+BEGIN_SRC emacs-lisp 1288 | (defconst blaine/bib-libraries (list "/Users/blaine/Documents/global.bib")) 1289 | #+END_SRC 1290 | 1291 | ** Retina display of PDFs 1292 | Combined with emacs-mac, this gives good PDF quality for [[https://www.aidanscannell.com/post/setting-up-an-emacs-playground-on-mac/][retina display]]. 1293 | #+BEGIN_SRC emacs-lisp 1294 | (setq pdf-view-use-scaling t) 1295 | #+END_SRC 1296 | 1297 | 1298 | ** PDF default page width behavior 1299 | #+BEGIN_SRC emacs-lisp 1300 | (setq-default pdf-view-display-size 'fit-page) 1301 | #+END_SRC 1302 | 1303 | 1304 | ** Set delay in the matching parenthesis to zero. 1305 | #+BEGIN_SRC emacs-lisp 1306 | (setq show-paren-delay 0) 1307 | (show-paren-mode t) 1308 | #+END_SRC 1309 | 1310 | 1311 | ** Window management 1312 | winner-mode C-c undo change C-c redo change 1313 | 1314 | #+BEGIN_SRC emacs-lisp 1315 | (winner-mode 1) 1316 | 1317 | (defun split-vertical-evenly () 1318 | (interactive) 1319 | (command-execute 'split-window-vertically) 1320 | (command-execute 'balance-windows)) 1321 | (global-set-key (kbd "C-x 2") 'split-vertical-evenly) 1322 | 1323 | (defun split-horizontal-evenly () 1324 | (interactive) 1325 | (command-execute 'split-window-horizontally) 1326 | (command-execute 'balance-windows)) 1327 | (global-set-key (kbd "C-x 3") 'split-horizontal-evenly) 1328 | #+END_SRC 1329 | 1330 | 1331 | ** Zoom text in and out. Very Sweet! 1332 | 1333 | #+BEGIN_SRC emacs-lisp 1334 | ;;;# Zoom in and out via C-scroll wheel 1335 | ;; (global-set-key [C-wheel-up] 'text-scale-increase) 1336 | ;; (global-set-key [C-wheel-down] 'text-scale-decrease) 1337 | (global-set-key [C-mouse-4] 'text-scale-increase) 1338 | (global-set-key [C-mouse-5] 'text-scale-decrease) 1339 | #+END_SRC 1340 | 1341 | 1342 | ** Aliases 1343 | Source: https://www.youtube.com/watch?v=ufVldIrUOBg 1344 | Defalias: a quick guide to making an alias in Emacs. 1345 | Usage: M-x ct 1346 | 1347 | #+BEGIN_SRC emacs-lisp 1348 | (defalias 'ct 'customize-themes) 1349 | (defalias 'cz 'customize) 1350 | (defalias 'ddl 'delete-duplicate-lines) 1351 | (defalias 'dga 'define-global-abbrev) 1352 | (defalias 'dma 'define-mode-abbrev) 1353 | (defalias 'ea 'edit-abbrevs) 1354 | (defalias 'ff 'flip-frame) 1355 | (defalias 'fl 'flush-lines) 1356 | (defalias 'fnd 'find-name-dired) 1357 | (defalias 'klm 'kill-matching-lines) 1358 | (defalias 'lc 'langtool-check) 1359 | (defalias 'lcu 'langtool-check-buffer) 1360 | (defalias 'lp 'list-packages) 1361 | (defalias 'pcr 'package-refresh-contents) 1362 | (defalias 'pi 'package-install) 1363 | (defalias 'pua 'package-upgrade-all) 1364 | (defalias 'qr 'query-replace) 1365 | (defalias 'rg 'rgrep) 1366 | (defalias 'rsv 'replace-smart-quotes) 1367 | (defalias 'sl 'sort-lines) 1368 | (defalias 'slo 'single-lines-only) 1369 | (defalias 'spe 'ispell-region) 1370 | (defalias 'udd 'package-upgrade-all) 1371 | (defalias 'ugg 'package-upgrade-all) 1372 | (defalias 'wr 'write-region) 1373 | #+END_SRC 1374 | 1375 | #+BEGIN_SRC emacs-lisp 1376 | (message "Finished global settings section.") 1377 | #+END_SRC 1378 | 1379 | 1380 | * A 1381 | #+BEGIN_SRC emacs-lisp 1382 | (message "Start package configurations A") 1383 | #+END_SRC 1384 | 1385 | 1386 | ** ace-window 1387 | 1388 | This is a window management package that allows you to switch between windows. 1389 | 1390 | #+BEGIN_SRC emacs-lisp 1391 | (global-set-key (kbd "M-o") 'ace-window) 1392 | ;; the list of initial characters used in window labels: 1393 | (setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)) 1394 | ;; default settings 1395 | (defvar aw-dispatch-alist 1396 | '((?x aw-delete-window "Delete Window") 1397 | (?m aw-swap-window "Swap Windows") 1398 | (?M aw-move-window "Move Window") 1399 | (?c aw-copy-window "Copy Window") 1400 | (?j aw-switch-buffer-in-window "Select Buffer") 1401 | (?n aw-flip-window) 1402 | (?u aw-switch-buffer-other-window "Switch Buffer Other Window") 1403 | (?c aw-split-window-fair "Split Fair Window") 1404 | (?v aw-split-window-vert "Split Vert Window") 1405 | (?b aw-split-window-horz "Split Horz Window") 1406 | (?o delete-other-windows "Delete Other Windows") 1407 | (?? aw-show-dispatch-help)) 1408 | "List of actions for `aw-dispatch-default'.") 1409 | #+END_SRC 1410 | 1411 | 1412 | ** auctex 1413 | #+BEGIN_SRC emacs-lisp 1414 | (use-package auctex 1415 | :ensure t 1416 | :defer t 1417 | :hook (LaTeX-mode . (lambda () 1418 | (push (list 'output-pdf "Skim") 1419 | TeX-view-program-selection)))) 1420 | #+END_SRC 1421 | 1422 | #+BEGIN_SRC emacs-lisp 1423 | (message "Finished A package configuraitons.") 1424 | #+END_SRC 1425 | 1426 | 1427 | * B 1428 | 1429 | 1430 | * C 1431 | 1432 | #+BEGIN_SRC emacs-lisp 1433 | (message "Start package configurations C") 1434 | #+END_SRC 1435 | 1436 | ** citar 1437 | 1438 | #+BEGIN_SRC emacs-lisp 1439 | (use-package citar 1440 | :bind (("C-c b" . citar-insert-citation) 1441 | :map minibuffer-local-map 1442 | ("M-b" . citar-insert-preset)) 1443 | :custom 1444 | (citar-bibliography '("/Users/blaine/Documents/global.bib")) 1445 | (citar-library-paths '("/Users/blaine/0papersLabeled") '("/Users/blaine/0booksUnlabeled")) 1446 | (citar-library-file-extensions '("pdf" "epub")) 1447 | :hook 1448 | ;; enable autocompletion in buffer of citekeys 1449 | (LaTeX-mode . citar-capf-setup) 1450 | (org-mode . citar-capf-setup)) 1451 | 1452 | (setenv "PATH" (concat "/usr/local/bin/:/opt/local/bin/" (getenv "PATH"))) 1453 | (add-to-list 'exec-path "/usr/local/bin:/opt/local/bin/") 1454 | #+END_SRC 1455 | 1456 | *** citar-org 1457 | 1458 | Use after org-cite. It is not loaded. 1459 | 1460 | #+BEGIN_SRC emacs-lisp 1461 | ; (use-package citar-org 1462 | ; :after oc 1463 | ; :custom 1464 | ; (org-cite-insert-processor 'citar) 1465 | ; (org-cite-follow-processor 'citar) 1466 | ; (org-cite-activate-processor 'citar) 1467 | ; :general 1468 | ; (:keymaps 'org-mode-map 1469 | ; :prefix "C-c b" 1470 | ; "b" '(citar-insert-citation :wk "Insert citation") 1471 | ; "r" '(citar-insert-reference :wk "Insert reference") 1472 | ; "o" '(citar-open-notes :wk "Open note")) 1473 | ; :custom 1474 | ; (citar-notes-paths '("/Users/blaine/org-roam/citar-org-roam")) ; List of directories for reference nodes 1475 | ; (citar-open-note-function 'orb-citar-edit-note) ; Open notes in `org-roam' 1476 | ; (citar-at-point-function 'embark-act) ; Use `embark' 1477 | ; ) 1478 | #+END_SRC 1479 | 1480 | *** cite-embark 1481 | #+BEGIN_SRC emacs-lisp 1482 | (use-package citar-embark 1483 | ;; get a table of options including opening related files and the entry in global.bib. 1484 | :after citar embark 1485 | :no-require 1486 | :config (citar-embark-mode)) 1487 | #+END_SRC 1488 | 1489 | 1490 | *** citar-org-roam 1491 | 1492 | 1493 | #+BEGIN_SRC emacs-lisp 1494 | (use-package citar-org-roam 1495 | :after (citar org-roam) 1496 | :no-require 1497 | :config (citar-org-roam-mode)) 1498 | #+END_SRC 1499 | 1500 | 1501 | #+BEGIN_SRC emacs-lisp 1502 | (message "Finished citar package configuration.") 1503 | #+END_SRC 1504 | 1505 | 1506 | #+BEGIN_SRC emacs-lisp 1507 | (use-package codeium 1508 | :load-path "/Users/blaine/e29org/manual-install/codeium.el/" 1509 | :init 1510 | ;; use globally 1511 | (add-to-list 'completion-at-point-functions #'codeium-completion-at-point) 1512 | ;; or on a hook 1513 | ;; (add-hook 'python-mode-hook 1514 | ;; (lambda () 1515 | ;; (setq-local completion-at-point-functions '(codeium-completion-at-point)))) 1516 | 1517 | ;; if you want multiple completion backends, use cape (https://github.com/minad/cape): 1518 | ;; (add-hook 'python-mode-hook 1519 | ;; (lambda () 1520 | ;; (setq-local completion-at-point-functions 1521 | ;; (list (cape-super-capf #'codeium-completion-at-point #'lsp-completion-at-point))))) 1522 | ;; an async company-backend is coming soon! 1523 | 1524 | ;; codeium-completion-at-point is autoloaded, but you can 1525 | ;; optionally set a timer, which might speed up things as the 1526 | ;; codeium local language server takes ~0.2s to start up 1527 | ;; (add-hook 'emacs-startup-hook 1528 | ;; (lambda () (run-with-timer 0.1 nil #'codeium-init))) 1529 | 1530 | ;; :defer t ;; lazy loading, if you want 1531 | 1532 | :config 1533 | (setq use-dialog-box nil) ;; do not use popup boxes 1534 | 1535 | ;; if you don't want to use customize to save the api-key 1536 | ;; (setq codeium/metadata/api_key "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") 1537 | 1538 | ;; get codeium status in the modeline 1539 | (setq codeium-mode-line-enable 1540 | (lambda (api) (not (memq api '(CancelRequest Heartbeat AcceptCompletion))))) 1541 | (add-to-list 'mode-line-format '(:eval (car-safe codeium-mode-line)) t) 1542 | ;; alternatively for a more extensive mode-line 1543 | ;; (add-to-list 'mode-line-format '(-50 "" codeium-mode-line) t) 1544 | 1545 | ;; use M-x codeium-diagnose to see apis/fields that would be sent to the local language server 1546 | (setq codeium-api-enabled 1547 | (lambda (api) 1548 | (memq api '(GetCompletions Heartbeat CancelRequest GetAuthToken RegisterUser auth-redirect AcceptCompletion)))) 1549 | ;; you can also set a config for a single buffer like this: 1550 | ;; (add-hook 'python-mode-hook 1551 | ;; (lambda () 1552 | ;; (setq-local codeium/editor_options/tab_size 4))) 1553 | 1554 | ;; You can overwrite all the codeium configs! 1555 | ;; for example, we recommend limiting the string sent to codeium for better performance 1556 | (defun my-codeium/document/text () 1557 | (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (min (+ (point) 1000) (point-max)))) 1558 | ;; if you change the text, you should also change the cursor_offset 1559 | ;; warning: this is measured by UTF-8 encoded bytes 1560 | (defun my-codeium/document/cursor_offset () 1561 | (codeium-utf8-byte-length 1562 | (buffer-substring-no-properties (max (- (point) 3000) (point-min)) (point)))) 1563 | (setq codeium/document/text 'my-codeium/document/text) 1564 | (setq codeium/document/cursor_offset 'my-codeium/document/cursor_offset) 1565 | ) 1566 | (message "Finished codeium package configuration") 1567 | #+END_SRC 1568 | 1569 | 1570 | ** corfu 1571 | #+BEGIN_SRC emacs-lisp 1572 | (message "Started corfu package configuration") 1573 | ;;;## Corfu configuration 1574 | (use-package corfu 1575 | :ensure t 1576 | :init 1577 | (setq tab-always-indent 'complete) 1578 | (global-corfu-mode) 1579 | :config 1580 | (setq corfu-auto t 1581 | corfu-echo-documentation t 1582 | corfu-scroll-margin 0 1583 | corfu-count 8 1584 | corfu-max-width 50 1585 | corfu-min-width corfu-max-width 1586 | corfu-auto-prefix 2) 1587 | 1588 | (corfu-history-mode 1) 1589 | (savehist-mode 1) 1590 | (add-to-list 'savehist-additional-variables 'corfu-history) 1591 | 1592 | (defun corfu-enable-always-in-minibuffer () 1593 | (setq-local corfu-auto nil) 1594 | (corfu-mode 1)) 1595 | (add-hook 'minibuffer-setup-hook #'corfu-enable-always-in-minibuffer 1) 1596 | ) 1597 | (message "Finished corfu package configuration") 1598 | #+END_SRC 1599 | 1600 | 1601 | ** Cape Configuration 1602 | 1603 | #+BEGIN_SRC emacs-lisp 1604 | (use-package cape 1605 | :ensure t 1606 | :init 1607 | (add-to-list 'completion-at-point-functions #'cape-file) 1608 | (add-to-list 'completion-at-point-functions #'cape-keyword) 1609 | ;; kinda confusing re length, WIP/TODO 1610 | ;; :hook (org-mode . (lambda () (add-to-list 'completion-at-point-functions #'cape-dabbrev))) 1611 | ;; :config 1612 | ;; (setq dabbrev-check-other-buffers nil 1613 | ;; dabbrev-check-all-buffers nil 1614 | ;; cape-dabbrev-min-length 6) 1615 | ) 1616 | #+END_SRC 1617 | 1618 | 1619 | ** company-box 1620 | 1621 | #+BEGIN_SRC emacs-lisp 1622 | (use-package company-box 1623 | :ensure t 1624 | :config 1625 | (setq company-box-max-candidates 50 1626 | company-frontends '(company-tng-frontend company-box-frontend) 1627 | company-box-icons-alist 'company-box-icons-all-the-icons)) 1628 | 1629 | (with-eval-after-load 'company 1630 | (define-key company-active-map 1631 | (kbd "TAB") 1632 | #'company-complete-common-or-cycle) 1633 | (define-key company-active-map 1634 | (kbd "") 1635 | (lambda () 1636 | (interactive) 1637 | (company-complete-common-or-cycle -1)))) 1638 | 1639 | (with-eval-after-load 'company 1640 | (define-key company-active-map (kbd "M-.") #'company-show-location) 1641 | (define-key company-active-map (kbd "RET") nil)) 1642 | #+END_SRC 1643 | 1644 | 1645 | ** Company Configuration 1646 | Source: https://github.com/Exafunction/codeium.el 1647 | 1648 | #+BEGIN_SRC emacs-lisp 1649 | (use-package company 1650 | :ensure t 1651 | :defer 0.1 1652 | :hook ((emacs-lisp-mode . (lambda () 1653 | (setq-local company-backends '(company-elisp)))) 1654 | (emacs-lisp-mode . company-mode)) 1655 | 1656 | :config 1657 | (global-company-mode t) 1658 | (company-tng-configure-default) ; restore old tab behavior 1659 | (setq-default 1660 | company-idle-delay 0.05 1661 | company-require-match nil 1662 | company-minimum-prefix-length 1 1663 | ;; get only preview 1664 | ;; company-frontends '(company-preview-frontend) 1665 | ;; also get a drop down 1666 | company-frontends '(company-pseudo-tooltip-frontend company-preview-frontend) 1667 | )) 1668 | #+END_SRC 1669 | 1670 | 1671 | ** consult 1672 | Extra Completion Functions 1673 | #+BEGIN_SRC emacs-lisp 1674 | (use-package consult 1675 | :ensure t 1676 | :after vertico 1677 | :bind (("C-x b" . consult-buffer) 1678 | ("C-x C-k C-k" . consult-kmacro) 1679 | ("C-x C-o" . consult-outline) 1680 | ("M-y" . consult-yank-pop) 1681 | ("M-g g" . consult-goto-line) 1682 | ("M-g M-g" . consult-goto-line) 1683 | ("M-g f" . consult-flymake) 1684 | ("M-g i" . consult-imenu) 1685 | ("M-s l" . consult-line) 1686 | ("M-s L" . consult-line-multi) 1687 | ("M-s u" . consult-focus-lines) 1688 | ("M-s g" . consult-ripgrep) 1689 | ("M-s M-g" . consult-ripgrep) 1690 | ("C-x C-SPC" . consult-global-mark) 1691 | ("C-x M-:" . consult-complex-command) 1692 | ; ("C-c n" . consult-org-agenda) 1693 | ("C-c m" . my/notegrep) 1694 | :map help-map 1695 | ("a" . consult-apropos) 1696 | :map minibuffer-local-map 1697 | ("M-r" . consult-history)) 1698 | :custom 1699 | (completion-in-region-function #'consult-completion-in-region) 1700 | :config 1701 | (defun my/notegrep () 1702 | "Use interactive grepping to search my notes" 1703 | (interactive) 1704 | (consult-ripgrep org-directory)) 1705 | (recentf-mode t)) 1706 | (use-package consult-dir 1707 | :ensure t 1708 | :bind (("C-x C-j" . consult-dir) 1709 | ;; :map minibuffer-local-completion-map 1710 | :map vertico-map 1711 | ("C-x C-j" . consult-dir))) 1712 | 1713 | (use-package consult-recoll 1714 | :bind (("M-s r" . counsel-recoll) 1715 | ("C-c I" . recoll-index)) 1716 | :init 1717 | (setq consult-recoll-inline-snippets t) 1718 | :config 1719 | (defun recoll-index (&optional arg) (interactive) 1720 | (start-process-shell-command "recollindex" 1721 | "*recoll-index-process*" 1722 | "recollindex"))) 1723 | #+END_SRC 1724 | 1725 | #+BEGIN_SRC 1726 | (message "Finished package configurations C") 1727 | #+END_SRC 1728 | 1729 | 1730 | 1731 | * D 1732 | 1733 | #+BEGIN_SRC emacs-lisp 1734 | (message "Start package configurations D") 1735 | #+END_SRC 1736 | 1737 | 1738 | ** dashboard 1739 | 1740 | #+BEGIN_SRC emacs-lisp 1741 | (use-package dashboard 1742 | :ensure t 1743 | :config 1744 | (dashboard-setup-startup-hook)) 1745 | (setq dashboard-center-content t) 1746 | (setq dashboard--ascii-banner-centered t) 1747 | (setq dashboard-banner-logo-title "Loxo or selpercatinib. FDA-approved RET kinase inhibitor to treat non-small cell lung cancer in 2020.") 1748 | (use-package all-the-icons) 1749 | ;;(insert (all-the-icons-icon-for-buffer)) 1750 | (setq dashboard-center-content t) 1751 | (setq dashboard-image-banner-max-width 120) 1752 | (setq dashboard-image-banner-max-height 150) 1753 | (use-package page-break-lines) 1754 | (setq dashboard-set-heading-icons t) 1755 | (setq dashboard-set-file-icons t) 1756 | (setq dashboard-startup-banner "/Users/blaine/images/loxoSmall.png") 1757 | (setq dashboard-items '((recents . 20) 1758 | (bookmarks . 50) 1759 | (projects . 250) 1760 | (registers . 5))) 1761 | 1762 | ;; (agenda . 15) 1763 | ;; Set the title 1764 | ;;(setq dashboard-banner-logo-title "Dashboard of Blaine Mooers") 1765 | ;; Set the banner 1766 | ;;(setq dashboard-startup-banner 'official) 1767 | ;;(setq dashboard-startup-banner "/Users/blaine/Images/jmjd4alphaFOld1Aug30.png") 1768 | ;; Value can be 1769 | ;; 'official which displays the official emacs logo 1770 | ;; 'logo which displays an alternative emacs logo 1771 | ;; 1, 2 or 3 which displays one of the text banners 1772 | ;; "path/to/your/image.gif", "path/to/your/image.png" or "path/to/your/text.txt" which displays whatever gif/image/text you would prefer 1773 | 1774 | ;; Content is not centered by default. To center, set 1775 | ;;(setq dashboard-center-content t) 1776 | 1777 | ;; To disable shortcut "jump" indicators for each section, set 1778 | (setq dashboard-show-shortcuts nil) 1779 | 1780 | ; To show info about the packages loaded and the init time: 1781 | (setq dashboard-set-init-info t) 1782 | 1783 | ; To use it with counsel-projectile or persp-projectile 1784 | (setq dashboard-projects-switch-function 'projectile-persp-switch-project) 1785 | 1786 | ; To display today’s agenda items on the dashboard, add agenda to dashboard-items: 1787 | (add-to-list 'dashboard-items '(agenda) t) 1788 | 1789 | ; To show agenda for the upcoming seven days set the variable dashboard-week-agenda to t. 1790 | (setq dashboard-week-agenda t) 1791 | #+END_SRC 1792 | 1793 | 1794 | 1795 | ** Dashboard refresh 1796 | 1797 | Function to refresh dashboard and open in the current window. 1798 | This function is useful for accessing bookmarks and recent files created in the current session. 1799 | The last line in the code bloack defines a global key binding to F1. 1800 | 1801 | Source of function by Jackson Benete Ferreira: the issues section of the [[https://github.com/emacs-dashboard/emacs-dashboard/issues/236][dashboard]] GitHub page. 1802 | I edited the documentation line to fix the grammar and add the final phrase. 1803 | 1804 | 1805 | #+BEGIN_SRC emacs-lisp 1806 | (defun new-dashboard () 1807 | "Jump to the dashboard buffer. If it doesn't exist, create one. Refresh while at it." 1808 | (interactive) 1809 | (switch-to-buffer dashboard-buffer-name) 1810 | (dashboard-mode) 1811 | (dashboard-insert-startupify-lists) 1812 | (dashboard-refresh-buffer)) 1813 | (global-set-key (kbd "") 'new-dashboard) 1814 | #+END_SRC 1815 | 1816 | 1817 | #+BEGIN_SRC 1818 | (message "Finished package configurations D") 1819 | #+END_SRC 1820 | 1821 | 1822 | * E 1823 | 1824 | 1825 | #+BEGIN_SRC emacs-lisp 1826 | (message "Start package configurations E") 1827 | #+END_SRC 1828 | 1829 | ** ekg 1830 | 1831 | https://github.com/ahyatt/ekg?tab=readme-ov-file 1832 | https://github.com/ahyatt/ekg/blob/develop/doc/ekg.org 1833 | https://github.com/ahyatt/llm 1834 | https://ollama.com/search?q=&c=embedding 1835 | https://ollama.com/library 1836 | #+BEGIN_SRC emacs-lisp 1837 | (use-package ekg 1838 | :bind (("C-c C-k" . ekg-capture)) 1839 | :init 1840 | (require 'ekg-embedding) 1841 | (ekg-embedding-generate-on-save) 1842 | (require 'ekg-llm) 1843 | (require 'llm-ollama) 1844 | :config 1845 | (require 'ekg-auto-save) 1846 | (add-hook 'ekg-capture-mode-hook #'ekg-auto-save-mode) 1847 | (add-hook 'ekg-edit-mode-hook #'ekg-auto-save-mode) 1848 | ) 1849 | ; (require 'llm-openai) ;; The specific provider you are using must be loaded. 1850 | ; (let ((my-provider (make-llm-openai :key "my-openai-api-key"))) 1851 | ; (setq ekg-llm-provider my-provider 1852 | ; ekg-embedding-provider my-provider))) 1853 | #+END_SRC 1854 | 1855 | 1856 | ** Embark 1857 | #+BEGIN_SRC emacs-lisp 1858 | (use-package embark 1859 | :ensure t 1860 | :bind 1861 | (("C-." . embark-act) ;; pick some comfortable binding 1862 | ("M-." . embark-dwim) ;; good alternative: M-. 1863 | ("C-h B" . embark-bindings)) ;; alternative for `describe-bindings' 1864 | 1865 | :init 1866 | 1867 | ;; Optionally replace the key help with a completing-read interface 1868 | (setq prefix-help-command #'embark-prefix-help-command) 1869 | 1870 | ;; Show the Embark target at point via Eldoc. You may adjust the Eldoc 1871 | ;; strategy, if you want to see the documentation from multiple providers. 1872 | (add-hook 'eldoc-documentation-functions #'embark-eldoc-first-target) 1873 | ;; (setq eldoc-documentation-strategy #'eldoc-documentation-compose-eagerly) 1874 | 1875 | :config 1876 | 1877 | ;; Hide the mode line of the Embark live/completions buffers 1878 | (add-to-list 'display-buffer-alist 1879 | '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*" 1880 | nil 1881 | (window-parameters (mode-line-format . none))))) 1882 | 1883 | ;; Consult users will also want the embark-consult package. 1884 | (use-package embark-consult 1885 | :ensure t ; only need to install it, embark loads it after consult if found 1886 | :hook 1887 | (embark-collect-mode . consult-preview-at-point-mode)) 1888 | #+END_SRC 1889 | 1890 | #+BEGIN_SRC 1891 | (message "Finished package configurations E") 1892 | #+END_SRC 1893 | 1894 | * F 1895 | 1896 | #+BEGIN_SRC emacs-lisp 1897 | (message "Started package configurations F") 1898 | #+END_SRC 1899 | 1900 | 1901 | ** flycheck 1902 | 1903 | #+BEGIN_SRC emacs-lisp 1904 | (use-package flycheck 1905 | :ensure t) 1906 | #+END_SRC 1907 | 1908 | #+BEGIN_SRC emacs-lisp 1909 | (message "Finished package configurations F") 1910 | #+END_SRC 1911 | 1912 | * G 1913 | 1914 | #+BEGIN_SRC emacs-lisp 1915 | (message "Started package configurations G") 1916 | #+END_SRC 1917 | 1918 | #+BEGIN_SRC emacs-lisp 1919 | (use-package general) 1920 | #+END_SRC 1921 | 1922 | #+BEGIN_SRC emacs-lisp 1923 | (message "Finished package configurations G") 1924 | #+END_SRC 1925 | 1926 | 1927 | * H 1928 | 1929 | 1930 | #+BEGIN_SRC emacs-lisp 1931 | (message "Start H packages configurations") 1932 | #+END_SRC 1933 | 1934 | ** hydra 1935 | 1936 | Source: https://github.com/jerrypnz/major-mode-hydra.el 1937 | 1938 | #+BEGIN_SRC emacs-lisp 1939 | (use-package major-mode-hydra 1940 | :bind 1941 | ("s-SPC" . major-mode-hydra)) 1942 | 1943 | (major-mode-hydra-define emacs-lisp-mode nil 1944 | ("Eval" 1945 | (("b" eval-buffer "buffer") 1946 | ("e" eval-defun "defun") 1947 | ("r" eval-region "region")) 1948 | "REPL" 1949 | (("I" ielm "ielm")) 1950 | "Test" 1951 | (("t" ert "prompt") 1952 | ("T" (ert t) "all") 1953 | ("F" (ert :failed) "failed")) 1954 | "Doc" 1955 | (("d" describe-foo-at-point "thing-at-pt") 1956 | ("f" describe-function "function") 1957 | ("v" describe-variable "variable") 1958 | ("i" info-lookup-symbol "info lookup")))) 1959 | 1960 | (message "Finished hydra package configurations") 1961 | #+END_SRC 1962 | 1963 | 1964 | 1965 | ** helpful 1966 | 1967 | #+BEGIN_SRC emacs-lisp 1968 | (use-package helpful) 1969 | 1970 | ;; Note that the built-in `describe-function' includes both functions 1971 | ;; and macros. `helpful-function' is functions only, so we provide 1972 | ;; `helpful-callable' as a drop-in replacement. 1973 | (global-set-key (kbd "C-h f") #'helpful-callable) 1974 | 1975 | (global-set-key (kbd "C-h v") #'helpful-variable) 1976 | (global-set-key (kbd "C-h k") #'helpful-key) 1977 | (global-set-key (kbd "C-h x") #'helpful-command) 1978 | 1979 | ;; Lookup the current symbol at point. C-c C-d is a common keybinding 1980 | ;; for this in lisp modes. 1981 | (global-set-key (kbd "C-c C-d") #'helpful-at-point) 1982 | 1983 | ;; Look up *F*unctions (excludes macros). 1984 | ;; 1985 | ;; By default, C-h F is bound to `Info-goto-emacs-command-node'. Helpful 1986 | ;; already links to the manual, if a function is referenced there. 1987 | (global-set-key (kbd "C-h F") #'helpful-function) 1988 | 1989 | (setq counsel-describe-function-function #'helpful-callable) 1990 | (setq counsel-describe-variable-function #'helpful-variable) 1991 | #+END_SRC 1992 | 1993 | 1994 | 1995 | #+BEGIN_SRC emacs-lisp 1996 | (message "Finished package configurations H") 1997 | #+END_SRC 1998 | 1999 | 2000 | 2001 | 2002 | * I 2003 | 2004 | #+BEGIN_SRC emacs-lisp 2005 | (message "Start I packages configurations") 2006 | #+END_SRC 2007 | 2008 | ** ivy 2009 | #+BEGIN_SRC emacs-lisp 2010 | (use-package counsel) 2011 | (use-package ivy 2012 | :diminish ivy-mode 2013 | :config 2014 | (setq ivy-extra-directories nil) ;; Hides . and .. directories 2015 | (setq ivy-initial-inputs-alist nil) ;; Removes the ^ in ivy searches 2016 | ; (if (eq jib/computer 'laptop) 2017 | ; (setq-default ivy-height 10) 2018 | ; (setq-default ivy-height 11)) 2019 | (setq ivy-fixed-height-minibuffer t) 2020 | (add-to-list 'ivy-height-alist '(counsel-M-x . 7)) ;; Don't need so many lines for M-x, I usually know what command I want 2021 | 2022 | ;;(ivy-mode 1) 2023 | 2024 | ;; Shows a preview of the face in counsel-describe-face 2025 | (add-to-list 'ivy-format-functions-alist '(counsel-describe-face . counsel--faces-format-function)) 2026 | 2027 | :general 2028 | (general-define-key 2029 | ;; Also put in ivy-switch-buffer-map b/c otherwise switch buffer map overrides and C-k kills buffers 2030 | :keymaps '(ivy-minibuffer-map ivy-switch-buffer-map) 2031 | "S-SPC" 'nil 2032 | "C-SPC" 'ivy-restrict-to-matches ;; Default is S-SPC, changed this b/c sometimes I accidentally hit S-SPC 2033 | ;; C-j and C-k to move up/down in Ivy 2034 | "C-k" 'ivy-previous-line 2035 | "C-j" 'ivy-next-line) 2036 | ) 2037 | 2038 | 2039 | ;;;; Nice icons in Ivy. Replaces all-the-icons-ivy. 2040 | ;;(use-package all-the-icons-ivy-rich 2041 | ;; :init (all-the-icons-ivy-rich-mode 1) 2042 | ;; :config 2043 | ;; (setq all-the-icons-ivy-rich-icon-size 1.0)) 2044 | #+END_SRC 2045 | 2046 | 2047 | ** ivy-rich 2048 | #+BEGIN_SRC emacs-lisp 2049 | (use-package ivy-rich 2050 | :after ivy 2051 | :init 2052 | (setq ivy-rich-path-style 'abbrev) 2053 | (setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line) 2054 | :config 2055 | (ivy-rich-mode 1)) 2056 | #+END_SRC 2057 | 2058 | ** ivy-bibtex 2059 | 2060 | #+BEGIN_SRC emacs-lisp 2061 | (use-package ivy-bibtex 2062 | :init 2063 | (setq bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 2064 | bibtex-completion-library-path '("/Users/blaine/0papersLabeled/" "/Users/blaine/0booksLabeled/") 2065 | bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 2066 | bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 2067 | bibtex-completion-additional-search-fields '(keywords) 2068 | bibtex-completion-display-formats 2069 | '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 2070 | (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 2071 | (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2072 | (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2073 | (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 2074 | bibtex-completion-pdf-open-function 2075 | (lambda (fpath) 2076 | (call-process "open" nil 0 nil fpath)))) 2077 | #+END_SRC 2078 | 2079 | 2080 | #+BEGIN_SRC emacs-lisp 2081 | (message "Finished I packages configurations") 2082 | #+END_SRC 2083 | 2084 | 2085 | 2086 | * J 2087 | * K 2088 | #+BEGIN_SRC emacs-lisp 2089 | (message "Started K packages configurations") 2090 | #+END_SRC 2091 | 2092 | ** Kind-Icon Configuration 2093 | 2094 | #+BEGIN_SRC emacs-lisp 2095 | (use-package kind-icon 2096 | :config 2097 | (setq kind-icon-default-face 'corfu-default) 2098 | (setq kind-icon-default-style '(:padding 0 :stroke 0 :margin 0 :radius 0 :height 0.9 :scale 1)) 2099 | (setq kind-icon-blend-frac 0.08) 2100 | (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter) 2101 | (add-hook 'counsel-load-theme #'(lambda () (interactive) (kind-icon-reset-cache))) 2102 | (add-hook 'load-theme #'(lambda () (interactive) (kind-icon-reset-cache)))) 2103 | #+END_SRC 2104 | 2105 | #+BEGIN_SRC emacs-lisp 2106 | (message "Finished K packages configurations") 2107 | #+END_SRC 2108 | 2109 | 2110 | * L 2111 | 2112 | #+BEGIN_SRC emacs-lisp 2113 | (message "Started L packages configurations") 2114 | #+END_SRC 2115 | 2116 | 2117 | 2118 | ** lsp-mode 2119 | 2120 | #+BEGIN_SRC emacs-lisp 2121 | (message "Started L packages configurations") 2122 | (use-package llm 2123 | :load-path "/Users/blaine/e29org/manual-install/llm.git/" 2124 | :init 2125 | ) 2126 | #+END_SRC 2127 | 2128 | ** lsp-mode 2129 | 2130 | 2131 | 2132 | 2133 | ** org-ai 2134 | 2135 | #+BEGIN_SRC emacs-lisp 2136 | ; (use-package org-ai 2137 | ; :load-path "/Users/blaine/emacs29.3/manual-packages/org-ai/" 2138 | ; :commands (org-ai-mode 2139 | ; org-ai-global-mode) 2140 | ; :init 2141 | ; (add-hook 'org-mode-hook #'org-ai-mode) ; enable org-ai in org-mode 2142 | ; (org-ai-global-mode) ; installs global keybindings on C-c M-a 2143 | ; :config 2144 | ; (setq org-ai-default-chat-model "gpt-4") ; if you are on the gpt-4 beta: 2145 | ; (org-ai-install-yasnippets)) ; if you are using yasnippet and want `ai` snippets 2146 | #+END_SRC 2147 | 2148 | ** org-babel 2149 | 2150 | Org-babel supports literate programming in org in many programming languages. 2151 | The coolest /language/ is /jupyter/. 2152 | This means that you can access any of the jupyter kernels from within org-mode. 2153 | This includes the PyMOL kernel. 2154 | This is super powerful. 2155 | 2156 | #+BEGIN_SRC emacs-lisp 2157 | (message "Started org-babel configuration.") 2158 | (org-babel-do-load-languages 2159 | 'org-babel-load-languages 2160 | '((emacs-lisp . t) 2161 | (shell . t) 2162 | (c . nil) 2163 | (cpp . nil) 2164 | (clojure . t) 2165 | (F90 . nil) 2166 | (gnuplot . t) 2167 | (js . nil) 2168 | (ditaa . nil) 2169 | (java . t) 2170 | (mathematica . nil) 2171 | (plantuml . nil) 2172 | (lisp . t) 2173 | (org . t) 2174 | (julia . t) 2175 | (python . t) 2176 | (R . t) 2177 | (jupyter . t)) 2178 | ) 2179 | ;; Removed ~(jupyter . t)~ on May 14 due to an error message. 2180 | ;; By default, you need to specify julia-vterm as the language name for source blocks. 2181 | ;; To use julia as the language name, define the following aliases. 2182 | ;; (defalias 'org-babel-execute:julia 'org-babel-execute:julia-vterm) 2183 | ;; (defalias 'org-babel-variable-assignments:julia 'org-babel-variable-assignments:julia-vterm) 2184 | (message "Finished org-babel configuration.") 2185 | #+END_SRC 2186 | 2187 | ** org-cc 2188 | 2189 | #+BEGIN_SRC emacs-lisp 2190 | ;; Context clues 2191 | ;; source https://github.com/durableOne/org-cc 2192 | (add-to-list 'load-path "/Users/blaine/emacs29.3/manual-packages/org-cc") 2193 | (use-package org-cc 2194 | :ensure nil 2195 | :after org 2196 | :custom 2197 | (org-cc-directory (concat org-directory "org-cc")) ;; subdirectory of the heading's attachment directory 2198 | (org-cc-days 14) 2199 | :init 2200 | (add-hook 'org-clock-in-hook #'org-cc-display-notes) 2201 | ) 2202 | (global-set-key (kbd "C-c k") 'org-cc-edit-cc-file) 2203 | (global-set-key (kbd "C-c x") 'org-cc-display-notes) 2204 | 2205 | (message "Finished org-cc. Line 15--.") 2206 | ;; org-caputre templates 2207 | 2208 | (setq org-capture-templates 2209 | '(("r" "Record" 2210 | plain 2211 | (file "/Users/blaine/org/notes.org") 2212 | "* %^{Title} :%^{Tags}:\n%U%i\n%?\n"))) 2213 | 2214 | (global-set-key (kbd "C-c t") 'org-tags-view) 2215 | 2216 | (message "Finished org-capture configuration.") 2217 | #+END_SRC 2218 | 2219 | 2220 | ** org-gtd 2221 | 2222 | # #+BEGIN_SRC emacs-lisp 2223 | # (setq org-gtd-update-ack "3.0.0") 2224 | # (use-package quelpa) 2225 | # (use-package quelpa-use-package) 2226 | # 2227 | # (use-package org-gtd 2228 | # ; :ensure t 2229 | # :after org 2230 | # :quelpa (org-gtd :fetcher github :repo "trevoke/org-gtd.el" 2231 | # :commit "3.0.0" :upgrade t) 2232 | # :demand t 2233 | # :custom 2234 | # (org-gtd-directory "~/org-gtd") 2235 | # (org-edna-use-inheritance t) 2236 | # (org-gtd-organize-hooks '(org-gtd-set-area-of-focus org-set-tags-command)) 2237 | # :config 2238 | # (org-edna-mode) 2239 | # :bind 2240 | # (("C-c d c" . org-gtd-capture) 2241 | # ("C-c d e" . org-gtd-engage) 2242 | # ("C-c d p" . org-gtd-process-inbox) 2243 | # :map org-gtd-clarify-map 2244 | # ("C-c c" . org-gtd-organize))) 2245 | # (message "Finished org-gtd configuration.") 2246 | # #+END_SRC 2247 | 2248 | 2249 | ** org-noter 2250 | 2251 | #+BEGIN_SRC emacs-lisp 2252 | (message "Started org-noter configuration. Line 1530.") 2253 | (use-package org-noter) 2254 | ;;*** Org-pdf-noter 2255 | ;; This commented out config sort of worked. 2256 | (use-package org-noter 2257 | :after org 2258 | :config 2259 | ;; Your org-noter config ........ 2260 | :config 2261 | (setq 2262 | org_notes (concat (getenv "HOME") "/org-roam/") 2263 | zot_bib (concat (getenv "HOME") "/Documents/global.bib") 2264 | org-directory org_notes 2265 | deft-directory org_notes 2266 | org-roam-directory org_notes 2267 | ;; keep an empty line between headings and content in Org file 2268 | org-noter-separate-notes-from-heading t) 2269 | (require 'org-noter-pdftools)) 2270 | #+END_SRC 2271 | 2272 | 2273 | ** org-pdftools 2274 | 2275 | #+BEGIN_SRC emacs-lisp 2276 | (use-package org-pdftools 2277 | :hook (org-mode . org-pdftools-setup-link)) 2278 | #+END_SRC 2279 | 2280 | 2281 | ** org-noter-pdftools 2282 | 2283 | #+BEGIN_SRC emacs-lisp 2284 | (use-package org-noter-pdftools 2285 | :after org-noter 2286 | :config 2287 | ;; Add a function to ensure precise note is inserted 2288 | (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions) 2289 | (interactive "P") 2290 | (org-noter--with-valid-session 2291 | (let ((org-noter-insert-note-no-questions (if toggle-no-questions 2292 | (not org-noter-insert-note-no-questions) 2293 | org-noter-insert-note-no-questions)) 2294 | (org-pdftools-use-isearch-link t) 2295 | (org-pdftools-use-freepointer-annot t)) 2296 | (org-noter-insert-note (org-noter--get-precise-info))))) 2297 | 2298 | ;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf 2299 | (defun org-noter-set-start-location (&optional arg) 2300 | "When opening a session with this document, go to the current location. 2301 | With a prefix ARG, remove start location." 2302 | (interactive "P") 2303 | (org-noter--with-valid-session 2304 | (let ((inhibit-read-only t) 2305 | (ast (org-noter--parse-root)) 2306 | (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive)))) 2307 | (with-current-buffer (org-noter--session-notes-buffer session) 2308 | (org-with-wide-buffer 2309 | (goto-char (org-element-property :begin ast)) 2310 | (if arg 2311 | (org-entry-delete nil org-noter-property-note-location) 2312 | (org-entry-put nil org-noter-property-note-location 2313 | (org-noter--pretty-print-location location)))))))) 2314 | (with-eval-after-load 'pdf-annot 2315 | (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note))) 2316 | 2317 | (use-package pdf-tools-org-noter-helpers 2318 | :pin manual 2319 | :load-path "/Users/blaine/emacs29.3/manual-packages/pdf-tools-org-noter-helpers/") 2320 | #+END_SRC 2321 | 2322 | 2323 | ** org-pomodoro 2324 | 2325 | #+BEGIN_SRC emacs-lisp 2326 | ;; (shell-command-to-string "open -a tomighty.app") 2327 | (use-package org-pomodoro 2328 | :commands (org-pomodoro) 2329 | :config 2330 | (setq alert-user-configuration (quote ((((:category . "org-pomodoro")) libnotify nil))))) 2331 | 2332 | ;; add hook to enable automated start of the next pom after a break. 2333 | ;; Source: https://github.com/marcinkoziej/org-pomodoro/issues/32 2334 | ;; (add-hook 'org-pomodoro-break-finished-hook 2335 | ;; (lambda () 2336 | ;; (interactive) 2337 | ;; (point-to-register 1) 2338 | ;; (org-clock-goto) 2339 | ;; (org-pomodoro '(25)) 2340 | ;; (register-to-point 1) 2341 | ;; (shell-command-to-string "open -a tomighty.app") 2342 | ;; )) 2343 | 2344 | (use-package sound-wav) 2345 | (setq org-pomodoro-ticking-sound-p nil) 2346 | (setq org-pomodoro-ticking-sound-states '(:pomodoro :short-break :long-break)) 2347 | (setq org-pomodoro-ticking-sound-states '(:pomodoro)) 2348 | (setq org-pomodoro-ticking-frequency 1) 2349 | (setq org-pomodoro-audio-player "mplayer") 2350 | (setq org-pomodoro-finished-sound-args "-volume 0.9") 2351 | (setq org-pomodoro-long-break-sound-args "-volume 0.9") 2352 | (setq org-pomodoro-short-break-sound-args "-volume 0.9") 2353 | (setq org-pomodoro-ticking-sound-args "-volume 0.3") 2354 | 2355 | (global-set-key (kbd "C-c o") 'org-pomodoro) 2356 | (message "Finished org-pomodoros configuration. Line 1607.") 2357 | #+END_SRC 2358 | 2359 | 2360 | 2361 | # #+BEGIN_SRC emacs-lisp 2362 | # ; (message "Start org-ref configuration. Line 1610.") 2363 | # ; ;; John Kitchin's config on YouTube https://www.youtube.com/watch?v=3u6eTSzHT6s 2364 | # ; ; (use-package ivy-bibtex 2365 | # ; ; :init 2366 | # ; ; (setq bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 2367 | # ; ; bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 2368 | # ; ; bibtex-completion-additional-search-fields '(keywords) 2369 | # ; ; bibtex-completion-display-formats 2370 | # ; ; '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 2371 | # ; ; (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 2372 | # ; ; (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2373 | # ; ; (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2374 | # ; ; (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 2375 | # ; ; bibtex-completion-pdf-open-function 2376 | # ; ; (lambda (fpath) 2377 | # ; ; (call-process "open" nil 0 nil fpath))) 2378 | # ; ; ) 2379 | # #+END_SRC 2380 | 2381 | ** org-ref 2382 | Set the case of the Author and Title to Capitalize with customize. 2383 | 2384 | #+BEGIN_SRC emacs-lisp 2385 | (message "Start org-ref configuration.") 2386 | (use-package org-ref 2387 | :init 2388 | (use-package bibtex) 2389 | (setq bibtex-autokey-year-length 4 2390 | bibtex-autokey-name-year-separator "" 2391 | bibtex-autokey-year-title-separator "" 2392 | bibtex-autokey-titleword-separator "" 2393 | bibtex-autokey-titlewords 9 2394 | bibtex-autokey-titlewords-stretch 9 2395 | bibtex-autokey-titleword-length 15) 2396 | ;; H is the hyper key. I have bound H to Fn. For the MacAlly keyboard, it is bound to right-command. 2397 | (define-key bibtex-mode-map (kbd "H-b") 'org-ref-bibtex-hydra/body) 2398 | ;; (use-package org-ref-ivy) 2399 | (setq org-ref-insert-link-function 'org-ref-insert-link-hydra/body 2400 | org-ref-insert-cite-function 'org-ref-cite-insert-ivy 2401 | org-ref-insert-label-function 'org-ref-insert-label-link 2402 | org-ref-insert-ref-function 'org-ref-insert-ref-link 2403 | org-ref-cite-onclick-function (lambda (_) (org-ref-citation-hydra/body))) 2404 | ; (use-package org-ref-arxiv) 2405 | ; (use-package org-ref-pubmed) 2406 | ; (use-package org-ref-wos) 2407 | ) 2408 | #+END_SRC 2409 | 2410 | 2411 | #+BEGIN_SRC emacs-lisp 2412 | (message "Start bibtex-completion-bibliography configuration of org-ref.") 2413 | (setq bibtex-completion-bibliography '("/Users/blaine/Documents/global.bib") 2414 | bibtex-completion-library-path '("/Users/blaine/0papersLabeled/" "/Users/blaine/0booksLabeled/") 2415 | bibtex-completion-notes-path "/Users/blaine/org-roam/references/notes/" 2416 | bibtex-completion-notes-template-multiple-files "* ${author-or-editor}, ${title}, ${journal}, (${year}) :${=type=}: \n\nSee [[cite:&${=key=}]]\n" 2417 | bibtex-completion-additional-search-fields '(keywords) 2418 | bibtex-completion-display-formats 2419 | '((article . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${journal:40}") 2420 | (inbook . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} Chapter ${chapter:32}") 2421 | (incollection . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2422 | (inproceedings . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*} ${booktitle:40}") 2423 | (t . "${=has-pdf=:1}${=has-note=:1} ${year:4} ${author:36} ${title:*}")) 2424 | bibtex-completion-pdf-open-function 2425 | (lambda (fpath) 2426 | (call-process "open" nil 0 nil fpath))) 2427 | 2428 | (setq bibtex-autokey-year-length 4 2429 | bibtex-autokey-name-year-separator "-" 2430 | bibtex-autokey-year-title-separator "-" 2431 | bibtex-autokey-titleword-separator "-" 2432 | bibtex-autokey-titlewords 2 2433 | bibtex-autokey-titlewords-stretch 1 2434 | bibtex-autokey-titleword-length 5) 2435 | (message "Finished bibtex-completion-bibliography configuration of org-ref. Line 1691.") 2436 | ;; H is the hyper key. I have bound H to Fn. For the MacAlly keyboard, it is bound to right-command. 2437 | (define-key bibtex-mode-map (kbd "s-b") 'org-ref-bibtex-hydra/body) 2438 | (define-key org-mode-map (kbd "s-i") org-ref-insert-cite-function) 2439 | (define-key org-mode-map (kbd "s-r") org-ref-insert-ref-function) 2440 | (define-key org-mode-map (kbd "H-l") org-ref-insert-label-function) 2441 | (define-key org-mode-map (kbd "H-d") 'doi-add-bibtex-entry) 2442 | #+END_SRC 2443 | 2444 | 2445 | ** org-cite-insert 2446 | 2447 | #+BEGIN_SRC emacs-lisp 2448 | (setq org-ref-insert-cite-function 2449 | (lambda () 2450 | (org-cite-insert nil))) 2451 | (message "Finished org-cite configurations") 2452 | #+END_SRC 2453 | 2454 | 2455 | ** org-roam 2456 | 2457 | #+BEGIN_SRC emacs-lisp 2458 | (message "Start org-roam configurations") 2459 | (use-package org-roam 2460 | :custom 2461 | (org-roam-directory (file-truename "/Users/blaine/org-roam/")) 2462 | :bind (("C-c n l" . org-roam-buffer-toggle) 2463 | ("C-c n f" . org-roam-node-find) 2464 | ("C-c n g" . org-roam-graph) 2465 | ("C-c n i" . org-roam-node-insert) 2466 | ("C-c n c" . #'org-id-get-create) 2467 | ;; Dailies 2468 | ("C-c n j" . org-roam-dailies-capture-today)) 2469 | :config 2470 | ;; If you're using a vertical completion framework, you might want a more informative completion interface 2471 | (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 2472 | (org-roam-db-autosync-mode)) 2473 | ;;(org-roam-ui-mode)) 2474 | ;; If using org-roam-protocol 2475 | ;;(use-package org-roam-protocol)) 2476 | 2477 | 2478 | ;; Following https://jethrokuan.github.io/org-roam-guide/ 2479 | (message "Start org-roam-capture template configurations.") 2480 | #+END_SRC 2481 | 2482 | ** org-roam-capture-templates 2483 | 2484 | #+BEGIN_SRC emacs-lisp 2485 | (setq org-roam-capture-templates 2486 | '(("p" "permanent" plain 2487 | "%?" 2488 | :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") 2489 | :immediate-finish t 2490 | :unnarrowed t) 2491 | ;; citar literature note 2492 | ; ("n" "literature note" plain 2493 | ; "%?" 2494 | ; :target (file+head "%(expand-file-name (or citar-org-roam-subdir \"\") org-roam-directory)/${citar-citekey}.org" 2495 | ; "#+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") 2496 | ; :unnarrowed t) 2497 | ("r" "reference" plain "%?" 2498 | :if-new 2499 | (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") 2500 | :immediate-finish t 2501 | :unnarrowed t) 2502 | ("l" "clipboard" plain #'org-roam-capture--get-point "%i%a" 2503 | :file-name "%<%Y%m%d%H%M%S>-${slug}" 2504 | :head "#+title: ${title}\n#+created: %u\n#+last_modified: %U\n#+ROAM_TAGS: %?" 2505 | :unnarrowed t 2506 | :prepend t 2507 | :jump-to-captured t) 2508 | ;; Vidianos G's config with ivy-bibtex 2509 | ("v" "bibliography reference" plain 2510 | "%?" 2511 | : if-new 2512 | (file+head "ref/${citekey}.org" "#+title: ${title}\n 2513 | ,#+filetags: ${entry-type} 2514 | - keywords :: ${keywords} 2515 | - tags :: 2516 | 2517 | ,* Analysis of ${entry-type} by ${author} 2518 | 2519 | 2520 | 2521 | * References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n 2522 | :PROPERTIES: 2523 | :URL: ${Url} 2524 | :NOTER_DOCUMENT: ${file} 2525 | :NOTER_PAGE: 2526 | :END:") 2527 | :unnarrowed t 2528 | :jump-to-captured t) 2529 | ("b" "bibliography notes" plain ; Org-noter integration 2530 | (file "~/org-roam/references/notes/notes-template.org") 2531 | :target (file+head "references/notes/${citekey}.org" 2532 | "#+title: ${title}\n :article:\n\n\n\n\n* References\n\n* Backlinks\n\n#+created_at: %U\n#+last_modified: %U\n") 2533 | :empty-lines 1) 2534 | ("a" "article" plain "%?" 2535 | :if-new 2536 | (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") 2537 | :immediate-finish t 2538 | :unnarrowed t))) 2539 | 2540 | (setq org-roam-node-display-template 2541 | (concat "${type:15} ${title:*} " (propertize "${tags:10}" 'face 'org-tag))) 2542 | #+END_SRC 2543 | 2544 | Writing technical documents requires us to write in paragraphs, 2545 | whereas org mode by default is intended to be used as an outliner, 2546 | to get around this problem, setting up org-export to preserve line breaks is useful 2547 | 2548 | #+BEGIN_SRC emacs-lisp 2549 | ;; (setq org-export-preserve-breaks t) 2550 | #+END_SRC 2551 | 2552 | 2553 | 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. 2554 | 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. 2555 | Put multiline code from mathpix between double dollar signs and treat as being on one line. 2556 | This trick does not work with the equation environment compressed to one line. You have to use M-x math-preview-region. 2557 | 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 2558 | 2559 | I ran out of time to time out how to render an active region. I need to find the analog of the latex-fragment: 2560 | 2561 | #+BEGIN_SRC emacs-lisp 2562 | ;; ('latex-???? (math-preview-region)) 2563 | ;; ???? has to be some kind of an org-element-type. org-latex-section does not work. 2564 | ;; This would enable using this application of the math-preview-region to render equation environments. 2565 | #+END_SRC 2566 | 2567 | 2568 | #+BEGIN_SRC emacs-lisp 2569 | (defun bhmm/toggle-state-at-point () 2570 | (interactive) 2571 | (let ((ctx (org-element-context))) 2572 | (pcase (org-element-type ctx) 2573 | ('link (org-toggle-link-display)) 2574 | ('latex-fragment (math-preview-at-point))))) 2575 | 2576 | (define-key org-mode-map (kbd "C-c t") #'bhmm/toggle-state-at-point) 2577 | (message "End toggle-state-at-point for use with images and equations.") 2578 | #+END_SRC 2579 | 2580 | 2581 | ** toc-org 2582 | 2583 | Place a ~:TOC:~ at the top of a file by a headline like table of contents, and it will be automatically inserted into the table of contents. 2584 | 2585 | # +BEGIN_SRC emacs-lisp 2586 | # (if (require 'toc-org nil t) 2587 | # (progn 2588 | # (add-hook 'org-mode-hook 'toc-org-mode) 2589 | # 2590 | # ;; enable in markdown, too 2591 | # (add-hook 'markdown-mode-hook 'toc-org-mode) 2592 | # (define-key markdown-mode-map (kbd "\C-c\C-o") 'toc-org-markdown-follow-thing-at-point)) 2593 | # (warn "toc-org not found")) 2594 | # +END_SRC 2595 | 2596 | #+BEGIN_SRC emacs-lisp 2597 | (message "End package configurations O") 2598 | #+END_SRC 2599 | 2600 | 2601 | * P 2602 | 2603 | #+BEGIN_SRC emacs-lisp 2604 | (message "Start package configurations O") 2605 | #+END_SRC 2606 | 2607 | ** pdf-tools 2608 | #+BEGIN_SRC emacs-lisp 2609 | (use-package pdf-tools 2610 | :pin manual ;; manually update 2611 | :config 2612 | ;; initialise 2613 | (pdf-tools-install) 2614 | ;; open pdfs scaled to fit width 2615 | (setq-default pdf-view-display-size 'fit-width) 2616 | ;; use normal isearch 2617 | (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward) 2618 | :custom 2619 | (pdf-annot-activate-created-annotations t "automatically annotate highlights")) 2620 | #+END_SRC 2621 | 2622 | ** perspective 2623 | #+BEGIN_SRC emacs-lisp 2624 | ;; per frame workspaces like on the Macs spaces 2625 | (use-package perspective 2626 | :ensure t 2627 | :bind 2628 | ("C-x C-b" . persp-list-buffers) ; or use a nicer switcher, see below 2629 | :custom 2630 | (persp-mode-prefix-key (kbd "C-c M-p")) ; pick your own prefix key here 2631 | :init 2632 | (persp-mode)) 2633 | #+END_SRC 2634 | 2635 | #+BEGIN_SRC emacs-lisp 2636 | (message "End package configurations P") 2637 | #+END_SRC 2638 | 2639 | * Q 2640 | 2641 | * R 2642 | 2643 | * S 2644 | 2645 | #+BEGIN_SRC emacs-lisp 2646 | message "Start package configurations S") 2647 | #+END_SRC 2648 | 2649 | 2650 | #+BEGIN_SRC emacs-lisp 2651 | ;;*** serenade (source: https://github.com/justin-roche/serenade-mode) 2652 | (use-package serenade-mode 2653 | :load-path "/Users/blaine/e29org/manual-install/serenade-mode/") 2654 | 2655 | (setq serenade-completion-frontend 'helm) 2656 | (setq serenade-helm-M-x t) 2657 | (setq serenade-snippet-engine 'yasnippet) 2658 | #+END_SRC 2659 | 2660 | #+BEGIN_SRC emacs-lisp 2661 | (message "End package configurations S") #+END_SRC 2662 | 2663 | 2664 | * T 2665 | #+BEGIN_SRC emacs-lisp 2666 | (message "Start package configurations T") 2667 | #+END_SRC 2668 | 2669 | ** treemacs 2670 | 2671 | C-x t t to launch treemacs 2672 | Support dragging files from the treemacs directory to a buffer to open them. 2673 | Default configuration for treemacs minus the treemacs-evil pacakge. 2674 | 2675 | #+BEGIN_SRC emacs-lisp 2676 | (use-package treemacs 2677 | :ensure t 2678 | :defer t 2679 | :init 2680 | (with-eval-after-load 'winum 2681 | (define-key winum-keymap (kbd "M-0") #'treemacs-select-window)) 2682 | :config 2683 | (progn 2684 | (setq treemacs-collapse-dirs (if treemacs-python-executable 3 0) 2685 | treemacs-deferred-git-apply-delay 0.5 2686 | treemacs-directory-name-transformer #'identity 2687 | treemacs-display-in-side-window t 2688 | treemacs-eldoc-display 'simple 2689 | treemacs-file-event-delay 2000 2690 | treemacs-file-extension-regex treemacs-last-period-regex-value 2691 | treemacs-file-follow-delay 0.2 2692 | treemacs-file-name-transformer #'identity 2693 | treemacs-follow-after-init t 2694 | treemacs-expand-after-init t 2695 | treemacs-find-workspace-method 'find-for-file-or-pick-first 2696 | treemacs-git-command-pipe "" 2697 | treemacs-goto-tag-strategy 'refetch-index 2698 | treemacs-header-scroll-indicators '(nil . "^^^^^^") 2699 | treemacs-hide-dot-git-directory t 2700 | treemacs-indentation 2 2701 | treemacs-indentation-string " " 2702 | treemacs-is-never-other-window nil 2703 | treemacs-max-git-entries 5000 2704 | treemacs-missing-project-action 'ask 2705 | treemacs-move-files-by-mouse-dragging t 2706 | treemacs-move-forward-on-expand nil 2707 | treemacs-no-png-images nil 2708 | treemacs-no-delete-other-windows t 2709 | treemacs-project-follow-cleanup nil 2710 | treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) 2711 | treemacs-position 'left 2712 | treemacs-read-string-input 'from-child-frame 2713 | treemacs-recenter-distance 0.1 2714 | treemacs-recenter-after-file-follow nil 2715 | treemacs-recenter-after-tag-follow nil 2716 | treemacs-recenter-after-project-jump 'always 2717 | treemacs-recenter-after-project-expand 'on-distance 2718 | treemacs-litter-directories '("/node_modules" "/.venv" "/.cask") 2719 | treemacs-project-follow-into-home nil 2720 | treemacs-show-cursor nil 2721 | treemacs-show-hidden-files t 2722 | treemacs-silent-filewatch nil 2723 | treemacs-silent-refresh nil 2724 | treemacs-sorting 'alphabetic-asc 2725 | treemacs-select-when-already-in-treemacs 'move-back 2726 | treemacs-space-between-root-nodes t 2727 | treemacs-tag-follow-cleanup t 2728 | treemacs-tag-follow-delay 1.5 2729 | treemacs-text-scale nil 2730 | treemacs-user-mode-line-format nil 2731 | treemacs-user-header-line-format nil 2732 | treemacs-wide-toggle-width 70 2733 | treemacs-width 35 2734 | treemacs-width-increment 1 2735 | treemacs-width-is-initially-locked t 2736 | treemacs-workspace-switch-cleanup nil) 2737 | 2738 | ;; The default width and height of the icons is 22 pixels. If you are 2739 | ;; using a Hi-DPI display, uncomment this to double the icon size. 2740 | ;;(treemacs-resize-icons 44) 2741 | 2742 | (treemacs-follow-mode t) 2743 | (treemacs-filewatch-mode t) 2744 | (treemacs-fringe-indicator-mode 'always) 2745 | (when treemacs-python-executable 2746 | (treemacs-git-commit-diff-mode t)) 2747 | 2748 | (pcase (cons (not (null (executable-find "git"))) 2749 | (not (null treemacs-python-executable))) 2750 | (`(t . t) 2751 | (treemacs-git-mode 'deferred)) 2752 | (`(t . _) 2753 | (treemacs-git-mode 'simple))) 2754 | 2755 | (treemacs-hide-gitignored-files-mode nil)) 2756 | :bind 2757 | (:map global-map 2758 | ("M-0" . treemacs-select-window) 2759 | ("C-x t 1" . treemacs-delete-other-windows) 2760 | ("C-x t t" . treemacs) 2761 | ("C-x t d" . treemacs-select-directory) 2762 | ("C-x t B" . treemacs-bookmark) 2763 | ("C-x t C-t" . treemacs-find-file) 2764 | ("C-x t M-t" . treemacs-find-tag))) 2765 | #+END_SRC 2766 | 2767 | 2768 | ** treemacs-projectile 2769 | 2770 | #+BEGIN_SRC emacs-lisp 2771 | (use-package treemacs-projectile 2772 | :after (treemacs projectile) 2773 | :ensure t) 2774 | #+END_SRC 2775 | 2776 | 2777 | ** treemacs-icons-dired 2778 | 2779 | #+BEGIN_SRC emacs-lisp 2780 | (use-package treemacs-icons-dired 2781 | :hook (dired-mode . treemacs-icons-dired-enable-once) 2782 | :ensure t) 2783 | #+END_SRC 2784 | 2785 | # #+BEGIN_SRC emacs-lisp 2786 | # ; (use-package treemacs-magit 2787 | # ; :after (treemacs magit) 2788 | # ; :ensure t) 2789 | # #+END_SRC 2790 | 2791 | ** treemacs-persp 2792 | #+BEGIN_SRC emacs-lisp 2793 | (use-package treemacs-persp ;;treemacs-perspective if you use perspective.el vs. persp-mode 2794 | :after (treemacs persp-mode) ;;or perspective vs. persp-mode 2795 | :ensure t 2796 | :config (treemacs-set-scope-type 'Perspectives)) 2797 | (treemacs-start-on-boot) 2798 | #+END_SRC 2799 | 2800 | 2801 | ** triples 2802 | 2803 | #+BEGIN_SRC emacs-lisp 2804 | (use-package triples 2805 | :load-path "/Users/blaine/e29org/manual-install/triples/") 2806 | #+END_SRC 2807 | 2808 | #+BEGIN_SRC emacs-lisp 2809 | (message "End package configurations T") 2810 | #+END_SRC 2811 | 2812 | 2813 | 2814 | * U 2815 | 2816 | #+BEGIN_SRC emacs-lisp 2817 | (message "Start package configurations U") 2818 | #+END_SRC 2819 | 2820 | ** undo-tree 2821 | 2822 | #+BEGIN_SRC emacs-lisp 2823 | (use-package undo-tree 2824 | :ensure t 2825 | :config 2826 | (global-undo-tree-mode 1)) 2827 | #+END_SRC 2828 | 2829 | #+BEGIN_SRC emacs-lisp 2830 | (message "End package configurations U") 2831 | #+END_SRC 2832 | 2833 | 2834 | * V 2835 | #+BEGIN_SRC emacs-lisp 2836 | (message "Start package configurations V") 2837 | #+END_SRC 2838 | 2839 | 2840 | ** Vertico Configuration 2841 | 2842 | #+BEGIN_SRC emacs-lisp 2843 | (use-package vertico 2844 | :ensure t 2845 | :init 2846 | (vertico-mode) 2847 | 2848 | ;; Different scroll margin 2849 | ;; (setq vertico-scroll-margin 0) 2850 | 2851 | ;; Show more candidates 2852 | (setq vertico-count 20) 2853 | 2854 | ;; Grow and shrink the Vertico minibuffer 2855 | (setq vertico-resize t) 2856 | 2857 | ;; Optionally enable cycling for `vertico-next' and `vertico-previous'. 2858 | (setq vertico-cycle t) 2859 | ) 2860 | #+END_SRC 2861 | 2862 | ** savehist 2863 | 2864 | #+BEGIN_SRC emacs-lisp 2865 | ;; Persist history over Emacs restarts. Vertico sorts by history position. 2866 | (use-package savehist 2867 | :ensure t 2868 | :init 2869 | (savehist-mode)) 2870 | #+END_SRC 2871 | 2872 | 2873 | ** emacs 2874 | 2875 | #+BEGIN_SRC emacs-lisp 2876 | ;; A few more useful configurations... 2877 | (use-package emacs 2878 | :ensure t 2879 | :init 2880 | ;; Add prompt indicator to `completing-read-multiple'. 2881 | ;; We display [CRM], e.g., [CRM,] if the separator is a comma. 2882 | (defun crm-indicator (args) 2883 | (cons (format "[CRM%s] %s" 2884 | (replace-regexp-in-string 2885 | "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" 2886 | crm-separator) 2887 | (car args)) 2888 | (cdr args))) 2889 | (advice-add #'completing-read-multiple :filter-args #'crm-indicator) 2890 | 2891 | ;; Do not allow the cursor in the minibuffer prompt 2892 | (setq minibuffer-prompt-properties 2893 | '(read-only t cursor-intangible t face minibuffer-prompt)) 2894 | (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) 2895 | 2896 | ;; Emacs 28: Hide commands in M-x which do not work in the current mode. 2897 | ;; Vertico commands are hidden in normal buffers. 2898 | ;; (setq read-extended-command-predicate 2899 | ;; #'command-completion-default-include-p) 2900 | 2901 | ;; Enable recursive minibuffers 2902 | (setq enable-recursive-minibuffers t)) 2903 | #+END_SRC 2904 | 2905 | #+BEGIN_SRC emacs-lisp 2906 | (message "Ended package configurations V") 2907 | #+END_SRC 2908 | 2909 | 2910 | * X 2911 | * W 2912 | #+BEGIN_SRC emacs-lisp 2913 | (message "Started package configurations W") 2914 | #+END_SRC 2915 | 2916 | 2917 | ** which-key 2918 | #+BEGIN_SRC emacs-lisp 2919 | (use-package which-key 2920 | :ensure t 2921 | :init 2922 | :defer 0 2923 | :diminish which-key-mode 2924 | :config 2925 | (which-key-mode) 2926 | (setq which-key-idle-delay 0.3)) 2927 | ;; (add-hook 'c-mode-hook 'lsp) 2928 | ;; (add-hook 'c++-mode-hook 'lsp) 2929 | (add-hook 'clojure-mode-hook 'lsp) 2930 | ;; (add-hook 'julia-mode-hook 'lsp) 2931 | (add-hook 'latex-mode-hook 'lsp) 2932 | (add-hook 'python-mode-hook 'lsp) 2933 | ;; (add-hook 'R-mode-hook 'lsp) 2934 | (which-key-setup-side-window-right-bottom) 2935 | (message "End package configurations W") 2936 | #+END_SRC 2937 | 2938 | #+BEGIN_SRC emacs-lisp 2939 | (message "Finished package configurations W") 2940 | #+END_SRC 2941 | 2942 | 2943 | * Y 2944 | 2945 | #+BEGIN_SRC emacs-lisp 2946 | (message "Start package configurations Y.") 2947 | #+END_SRC 2948 | 2949 | ** yasnippet 2950 | 2951 | #+BEGIN_SRC emacs-lisp 2952 | (use-package yasnippet 2953 | :config 2954 | (yas-global-mode 1)) 2955 | (global-set-key "\C-o" 'yas-expand) 2956 | (global-set-key "\C-c y i" 'yas-insert-snippet) 2957 | (global-set-key "\C-c y n" 'yas-new-snippet) 2958 | #+END_SRC 2959 | 2960 | ** my-hydras 2961 | 2962 | *** writing-projects-hydra 2963 | 2964 | #+BEGIN_SRC emacs-lisp 2965 | (use-package writing-projects-hydra 2966 | :load-path "~/emacs29.3/my-hydras/") 2967 | (global-set-key (kbd "C-c 9") 'writing-projects-hydra/body) 2968 | #+END_SRC 2969 | 2970 | 2971 | *** learning-packages-and-modes-hydras 2972 | 2973 | #+BEGIN_SRC emacs-lisp 2974 | (use-package learning-packages-and-modes-hydras 2975 | :load-path "~/emacs29.3/my-hydras/") 2976 | (global-set-key (kbd "C-c 2") 'learning-packages-and-modes-hydras/body) 2977 | #+END_SRC 2978 | 2979 | 2980 | *** learning-spiral-hydras 2981 | 2982 | #+BEGIN_SRC emacs-lisp 2983 | (use-package learning-spiral-hydras 2984 | :load-path "~/emacs29.3/my-hydras/") 2985 | (global-set-key (kbd "C-c 1") 'hydra-of-learning-spiral/body) 2986 | #+END_SRC 2987 | 2988 | 2989 | *** my-hydras 2990 | 2991 | #+BEGIN_SRC emacs-lisp 2992 | (use-package my-hydras 2993 | :load-path "~/emacs29.3/my-hydras/") 2994 | (global-set-key (kbd "C-c 0") 'hydra-of-hydras/body) 2995 | #+END_SRC 2996 | 2997 | 2998 | *** hydra 2999 | 3000 | A cool hydra for finding snippets at point. 3001 | Invoke with C-c y. 3002 | #+BEGIN_SRC emacs-lisp 3003 | (use-package hydra 3004 | :defer 2 3005 | :bind ("C-c y" . hydra-yasnippet/body)) 3006 | #+END_SRC 3007 | 3008 | 3009 | 3010 | ** popup 3011 | 3012 | #+BEGIN_SRC emacs-lisp 3013 | (use-package popup) 3014 | ;; add some shotcuts in popup menu mode 3015 | (define-key popup-menu-keymap (kbd "M-n") 'popup-next) 3016 | (define-key popup-menu-keymap (kbd "TAB") 'popup-next) 3017 | (define-key popup-menu-keymap (kbd "") 'popup-next) 3018 | (define-key popup-menu-keymap (kbd "") 'popup-previous) 3019 | (define-key popup-menu-keymap (kbd "M-p") 'popup-previous) 3020 | 3021 | (defun yas/popup-isearch-prompt (prompt choices &optional display-fn) 3022 | (when (featurep 'popup) 3023 | (popup-menu* 3024 | (mapcar 3025 | (lambda (choice) 3026 | (popup-make-item 3027 | (or (and display-fn (funcall display-fn choice)) 3028 | choice) 3029 | :value choice)) 3030 | choices) 3031 | :prompt prompt 3032 | ;; start isearch mode immediately 3033 | :isearch t 3034 | ))) 3035 | (setq yas/prompt-functions '(yas/popup-isearch-prompt yas/no-prompt)) 3036 | #+END_SRC 3037 | 3038 | #+BEGIN_SRC emacs-lisp 3039 | (use-package license-snippets 3040 | :load-path "/Users/blaine/emacs29.3/manual-packages/license-snippets") 3041 | (license-snippets-init) 3042 | #+END_SRC 3043 | 3044 | #+BEGIN_SRC emacs-lisp 3045 | (message "Fnished Y package configurations!!") 3046 | #+END_SRC 3047 | 3048 | 3049 | * Z 3050 | 3051 | #+BEGIN_SRC emacs-lisp 3052 | (message "Finished package configurations!!") 3053 | #+END_SRC 3054 | --------------------------------------------------------------------------------