diff options
Diffstat (limited to 'Emacs')
| -rw-r--r-- | Emacs/.config/emacs/config.org | 416 | 
1 files changed, 0 insertions, 416 deletions
diff --git a/Emacs/.config/emacs/config.org b/Emacs/.config/emacs/config.org index e77f573..794901f 100644 --- a/Emacs/.config/emacs/config.org +++ b/Emacs/.config/emacs/config.org @@ -74,52 +74,6 @@ Let's setup a few things:  * Custom functionality  Some Lisp I wrote that only depends on Emacs to provide some custom  functionality. -** WAIT Toggle buffer -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Like VSCode's toggling feature for just the terminal but now for -any buffer of choice, as long as I can generate it via a command. - -2024-04-23: Don't need this anymore due to -~switch-to-buffer-obey-display-actions~. -#+begin_src emacs-lisp -(with-eval-after-load "window" -  (defmacro +oreo/create-toggle-function (func-name buf-name -                                                    buf-create -                                                    &optional accept-numeric) -    "Generate a function named FUNC-NAME that toggles the buffer with -name BUF-NAME, using BUF-CREATE to generate it if buffer BUF-NAME -does not exist already. - -BUF-NAME cannot be a regexp, it must be a fixed name. - -ACCEPT-NUMERIC modifies the function to allow numeric arguments -via C-u.  Mostly used in Eshell." -    (let ((interactive-arg -           (if accept-numeric '(interactive "p") '(interactive))) -          (arguments -           (if accept-numeric '(&optional arg) nil)) -          (buffer-name (if accept-numeric -                           `(if (= arg 1) -                                ,buf-name -                              (concat ,buf-name "<" (int-to-string arg) ">")) -                         buf-name)) -          (buffer-create (if accept-numeric -                             `(if (= arg 1) -                                  (,buf-create) -                                (,buf-create arg)) -                           `(,buf-create)))) -      `(defun ,func-name ,arguments -         ,interactive-arg -         (let* ((buffer (or (get-buffer ,buffer-name) -                            ,buffer-create)) -                (displayed (get-buffer-window buffer))) -           (if displayed -               (delete-window displayed) -             (display-buffer buffer) -             (select-window (get-buffer-window buffer)))))))) -#+end_src  ** Automatically run a command on saving  Define a macro which creates hooks into the ~after-save-hook~.  On  certain ~conditions~ being met, ~to-run~ is evaluated. @@ -765,87 +719,6 @@ Setup for counsel.  Load after ivy and helpful.                                  (t . ivy--regex-ignore-order)))    (counsel-mode 1))  #+end_src -**** WAIT Ivy posframe -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -This makes ivy minibuffer windows use child frames. -Very nice eyecandy, but can get kinda annoying. -#+begin_src emacs-lisp -(use-package ivy-posframe -  :hook (ivy-mode-hook . ivy-posframe-mode) -  :straight t -  :init -  (setq ivy-posframe-parameters -        '((left-fringe      . 0) -          (right-fringe     . 0) -          (background-color . "grey7"))) - -  (setq ivy-posframe-display-functions-alist -        '((t . ivy-posframe-display-at-window-center)))) -#+end_src -**** WAIT Counsel etags -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Counsel etags allows me to search generated tag files for tags.  I -already have a function defined to generate the tags, so it's just -searching them which I find to be a bit of a hassle, and where this -package comes in. - -This has been replaced by [[*xref][xref]] which is inbuilt. -#+begin_src emacs-lisp -(use-package counsel-etags -  :after counsel -  :general -  (search-leader -    "t" #'counsel-etags-find-tag)) -#+end_src -*** WAIT Ido -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Ido is a very old completion package that still works great to this -day.  Though it is limited in its scope (and may thus be called a -completion add-on rather than a full on framework), it is still a very -powerful package.  With the use of ido-completing-read+, it may be used -similarly to a fully fledged completion framework. - -#+begin_src emacs-lisp -(use-package ido -  :demand t -  :general -  (general-def -    :keymaps '(ido-buffer-completion-map -               ido-file-completion-map -               ido-file-dir-completion-map -               ido-common-completion-map) -    (kbd "M-j")   #'ido-next-match -    (kbd "M-k")   #'ido-prev-match -    (kbd "C-x o") #'evil-window-up) -  :init -  (setq ido-decorations -        (list "{" "}" " \n" " ..." "[" "]" " [No match]" " [Matched]" -              " [Not readable]" " [Too big]" " [Confirm]") -        completion-styles '(flex partial-completion intials emacs22)) -  (setq-default ido-enable-flex-matching t -                ido-enable-dot-prefix t -                ido-enable-regexp nil) -  (with-eval-after-load "magit" -    (setq magit-completing-read-function 'magit-ido-completing-read)) -  :config -  (ido-mode) -  (ido-everywhere)) -#+end_src -**** Ido ubiquitous -Ido completing-read+ is a package that extends the ido package to work -with more text based functions. -#+begin_src emacs-lisp -(use-package ido-completing-read+ -  :after ido -  :config -  (ido-ubiquitous-mode +1)) -#+end_src  *** Amx  Amx is a fork of Smex that works to enhance the  execute-extended-command interface.  It also provides support for ido @@ -1102,32 +975,6 @@ with abstracting a few things away.     ("smon"      (format-time-string "%B" (current-time)))))  #+end_src -*** WAIT Skeletons -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Defines a macro for generating a skeleton + abbrev for a given mode. -Doesn't sanitise inputs because I assume callers are /rational/ actors -who would *only* use this for their top level Emacs config. - -Honestly didn't find much use for this currently, so disabled. -#+begin_src emacs-lisp -(use-package skeleton -  :after abbrev -  :config -  (defmacro +autotyping/gen-skeleton-abbrev (mode abbrev &rest skeleton) -    (let* ((table          (intern (concat (symbol-name mode) "-abbrev-table"))) -           (skeleton-name  (intern (concat "+skeleton/" (symbol-name mode) "/" abbrev)))) -      `(progn -         (define-skeleton -           ,skeleton-name -           "" -           ,@skeleton) -         (define-abbrev ,table -           ,abbrev -           "" -           ',skeleton-name))))) -#+end_src  *** Auto insert  Allows inserting text immediately upon creating a new buffer with a  given name.  Supports skeletons for inserting text.  To make it easier @@ -1556,54 +1403,6 @@ directories particularly efficiently.  Emacs is basically an operating system whose primary datatype is text.  Applications are interfaces/environments which serve a variety of  purposes, but provide a lot of capability. -** WAIT Dashboard -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Dashboard creates a custom dashboard for Emacs that replaces the -initial startup screen in default Emacs.  It has a lot of customising -options. - -Unfortunately not that useful, many things are easier to invoke -directly such as recent files or project changing. -#+begin_src emacs-lisp -(use-package dashboard -  :straight t -  :demand t -  :general -  (app-leader -    "b" #'dashboard-refresh-buffer) -  (:states '(normal motion emacs) -   :keymaps 'dashboard-mode-map -   "q" (proc (interactive) (kill-this-buffer))) -  (nmmap -    :keymaps 'dashboard-mode-map -    "r" #'dashboard-jump-to-recent-files -    "p" #'dashboard-jump-to-projects -    "}" #'dashboard-next-section -    "{" #'dashboard-previous-section) -  :init -  (setq initial-buffer-choice nil -        dashboard-banner-logo-title "Oreomacs" -        dashboard-center-content t -        dashboard-set-init-info t -        dashboard-startup-banner (no-littering-expand-etc-file-name "dashboard/logo.png") -        dashboard-set-footer t -        dashboard-set-navigator t -        dashboard-items '((projects . 5) -                          (recents . 5)) -        dashboard-footer-messages (list -                                   "Collecting parentheses..." -                                   "Linking 'coffee_machine.o'..." -                                   "Uploading ip to hacker named 4chan..." -                                   "Dividing by zero..." -                                   "Solving 3-sat..." -                                   "Obtaining your health record..." -                                   (format "Recompiling Emacs for the %dth time..." (random 1000)) -                                   "Escaping the cycle of samsara...")) -  :config -  (dashboard-setup-startup-hook)) -#+end_src  ** EWW  Emacs Web Wowser is the inbuilt text based web browser for Emacs.  It  can render images and basic CSS styles but doesn't have a JavaScript @@ -1841,96 +1640,6 @@ easier than even using the mark based system.      "ZZ" #'wdired-finish-edit      "ZQ" #'wdired-abort-changes))  #+end_src -** WAIT Xwidget -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Xwidget is a package which allows for the insertion of arbitrary -xwidgets into Emacs through buffers.  It must be compiled into Emacs -so you might need to customise your install.  One of its premier uses -is in navigating the web which it provides through the function -~xwidget-webkit-browse-url~.  This renders a fully functional web -browser within Emacs. - -Though I am not to keen on using Emacs to browse the web /via/ xwidget -(EWW does a good job on its own), I am very interested in its -capability to render pages with JavaScript, as it may come of use when -doing web development.  I can see the results of work very quickly -without switching windows all within Emacs. - -2023-10-20: Disabled as it didn't seem to work, and honestly wasn't -that useful. -*** Xwidget Core -#+begin_src emacs-lisp -(use-package xwidget -  :general -  (app-leader -    "u" #'xwidget-webkit-browse-url) -  (nmmap -    :keymaps 'xwidget-webkit-mode-map -    "q"         #'quit-window -    "h"         #'xwidget-webkit-scroll-backward -    "j"         #'xwidget-webkit-scroll-up -    "k"         #'xwidget-webkit-scroll-down -    "l"         #'xwidget-webkit-scroll-forward -    "+"         #'xwidget-webkit-zoom-in -    "-"         #'xwidget-webkit-zoom-out -    (kbd "C-f") #'xwidget-webkit-scroll-up -    (kbd "C-b") #'xwidget-webkit-scroll-down -    "H"         #'xwidget-webkit-back -    "L"         #'xwidget-webkit-forward -    "gu"        #'xwidget-webkit-browse-url -    "gr"        #'xwidget-webkit-reload -    "gg"        #'xwidget-webkit-scroll-top -    "G"         #'xwidget-webkit-scroll-bottom)) -#+end_src -*** Xwidget Extensions -Define a function ~+xwidget/render-file~ that reads a file name and -presents it in an xwidget.  If the current file is an HTML file, ask -if user wants to open current file.  Bind it to ~aU~ in the leader. - -Also define a function ~+xwidget/search-query~ that first asks the -user what search engine they want to use -([[https://duckduckgo.com][Duck Duck Go]] and -[[https://devdocs.io][DevDocs]] currently) then asks for a query, -which it parses then presents in an xwidget window.  Bind to ~as~ in -the leader. -#+begin_src emacs-lisp -(use-package xwidget -  :commands (+xwidget/render-file +xwidget/search) -  :general -  (app-leader -    "U" #'+xwidget/render-file -    "s" #'+xwidget/search) -  :config -  (setenv "WEBKIT_FORCE_SANDBOX" "0") -  (defun +xwidget/render-file (&optional FORCE) -    "Find file (or use current file) and render in xwidget." -    (interactive) -    (cond -     ((and (not FORCE) (or (string= (replace-regexp-in-string ".*.html" -                                                              "html" (buffer-name)) "html") -                           (eq major-mode 'web-mode) -                           (eq major-mode 'html-mode))) ; If in html file -      (if (y-or-n-p "Open current file?: ") ; Maybe they want to open a separate file -          (xwidget-webkit-browse-url (format "file://%s" (buffer-file-name))) -        (+xwidget/render-file t))) ; recurse and open file via prompt -     (t -      (xwidget-webkit-browse-url -       (format "file://%s" (read-file-name "Enter file to open: ")))))) - -  (defun +xwidget/search () -    "Run a search query on some search engine and display in -xwidget." -    (interactive) -    (let* ((engine (completing-read "Engine: " '("duckduckgo.com" "devdocs.io") nil t)) -           (query-raw (read-string "Enter query: ")) -           (query -            (cond -             ((string= engine "duckduckgo.com") query-raw) -             ((string= engine "devdocs.io") (concat "_ " query-raw))))) -      (xwidget-webkit-browse-url (concat "https://" engine "/?q=" query))))) -#+end_src  ** Eshell  *** Why Eshell?  Eshell is an integrated shell environment for Emacs, written in Emacs @@ -2332,34 +2041,6 @@ back in, I can just do it within Emacs.  Pretty nifty, right?    (with-eval-after-load "evil-collection"      (evil-collection-calc-setup)))  #+end_src -*** WAIT Calctex -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -~calc-mode~ also has a 3rd party package called ~calctex~. It renders -mathematical expressions within calc as if they were rendered in TeX. -You can also copy the expressions in their TeX forms, which is pretty -useful when writing a paper.  I've set a very specific lock on this -repository as it's got quite a messy work-tree and this commit seems to -work for me given the various TeX utilities installed via Arch. - -#+begin_src emacs-lisp -(use-package calctex -  :after calc -  :straight (calctex :type git :host github :repo "johnbcoughlin/calctex") -  :hook (calc-mode-hook . calctex-mode)) -#+end_src -** WAIT Ledger -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -#+begin_src emacs-lisp -(use-package ledger-mode -  :defer t) - -(use-package evil-ledger -  :after ledger-mode) -#+end_src  ** Zone  Of course Emacs has a cool screensaver software. @@ -2447,25 +2128,6 @@ and integrates slickly into image-dired.  Of course,          erc-nick "oreodave"          erc-buffer-display "current"))  #+end_src -** WAIT MPV -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Basically a porcelain over mpv via the IPC interface. -#+begin_src emacs-lisp -(use-package mpv -  :defer t -  :straight t -  :config -  (with-eval-after-load "org" -    (defun org-mpv-complete-link (&optional arg) -      (replace-regexp-in-string -       "file:" "mpv:" -       (org-link-complete-file arg) -       t t)) -    (org-link-set-parameters "mpv" -                             :follow #'mpv-play :complete #'org-mpv-complete-link))) -#+end_src  * Text modes  Standard packages and configurations for text-mode and its derived  modes. @@ -2850,37 +2512,6 @@ quickly generate them in C/C++ projects.                 (visit-tags-table (concat (project-root (project-current)) "TAGS"))                 (message "Finished generating tags!")))))))))  #+end_src -** WAIT Projectile -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -Projectile is a project management package which integrates with Emacs -very well.  It essentially provides alternative Emacs commands scoped -to the current 'project', based on differing signs that a directory is -a 'project'. -#+begin_src emacs-lisp -(use-package projectile -  :hook (emacs-startup-hook . projectile-mode) -  :general -  (general-def -    :keymaps 'projectile-command-map -    "t" #'projectile-test-project -    "r" #'projectile-run-project -    "q" #'projectile-replace-regexp) -  (leader -    "p" '(projectile-command-map :which-key "Projectile")) -  :init -  (setq projectile-tags-command "ctags -Re -f \"%s\" %s \"%s\"" -        projectile-enable-caching t)) -#+end_src -*** Counsel projectile -Counsel integration for projectile commands, very nice. -#+begin_src emacs-lisp -(use-package counsel-projectile -  :after (projectile counsel) -  :config -  (counsel-projectile-mode +1)) -#+end_src  ** devdocs  #+begin_src emacs-lisp  (use-package devdocs @@ -3441,53 +3072,6 @@ $(DEPDIR):  "     _))  #+end_src -** PDF -I use PDFs mostly for reading reports or papers.  Though Emacs isn't -my preferred application for viewing PDFs (I highly recommend -[[https://pwmt.org/projects/zathura/][Zathura]]), similar to most -things with Emacs, having a PDF viewer builtin can be a very useful -asset. - -For example if I were editing an org document which I was eventually -compiling into a PDF, my workflow would be much smoother with a PDF -viewer within Emacs that I can open on another pane. -*** WAIT PDF tools -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -~pdf-tools~ provides the necessary functionality for viewing PDFs. -There is no proper PDF viewing without this package. -~evil-collection~ provides a setup for this mode, so use that. -#+begin_src emacs-lisp -(use-package pdf-tools -  :mode ("\\.[pP][dD][fF]\\'" . pdf-view-mode) -  :straight t -  :display -  ("^.*pdf$" -   (display-buffer-same-window) -   (inhibit-duplicate-buffer . t)) -  :config -  (pdf-tools-install-noverify) -  (with-eval-after-load "evil-collection" -    (evil-collection-pdf-setup))) -#+end_src -*** WAIT PDF grep -:PROPERTIES: -:header-args:emacs-lisp: :tangle no -:END: -PDF grep is a Linux tool that allows for searches against the text -inside of PDFs similar to standard grep.  This cannot be performed by -standard grep due to how PDFs are encoded; they are not a clear text -format. -#+begin_src emacs-lisp -(use-package pdfgrep -  :after pdf-tools -  :hook (pdf-view-mode-hook . pdfgrep-mode) -  :general -  (nmap -    :keymaps 'pdf-view-mode-map -    "M-g"    #'pdfgrep)) -#+end_src  ** WAIT SQL  :PROPERTIES:  :header-args:emacs-lisp: :tangle no  | 
