Compare commits

...

8 Commits

Author SHA1 Message Date
Aryadev Chavali
7339e74a71 Scripts/status: check if bluetooth controllers are even available 2025-11-24 16:42:16 +00:00
Aryadev Chavali
9bba43b567 textual adjustments in config 2025-11-18 06:58:01 +00:00
Aryadev Chavali
8b0ebb8254 split of C/C++ auto-insert into its own section. 2025-11-17 01:08:57 +00:00
Aryadev Chavali
9f32648119 WIP script to be able to lookup keybindings from SXHkD 2025-11-16 22:31:57 +00:00
Aryadev Chavali
9eb7582eff Script to check the dirty memory property of /proc/meminfo 2025-11-16 22:31:35 +00:00
Aryadev Chavali
7337d56786 Small changes 2025-11-16 22:31:24 +00:00
Aryadev Chavali
93be55b00a Better clean-buffer-list 2025-11-16 22:30:37 +00:00
Aryadev Chavali
711cdf555b Reintroduce reset-font-size 2025-11-16 22:30:30 +00:00
11 changed files with 374 additions and 212 deletions

View File

@@ -42,41 +42,43 @@ documentation *and* code. Here's an example of some Emacs Lisp code:
#+end_src
So how does this work? [[file:elisp/literate.el][Literate]] is a
package that I designed myself which "compiles" my configuration and
links it all together. The literate package compiles this document
by:
+ collecting all the Emacs Lisp blocks
+ concatenating them
+ writing it to =config.el=,
Then, when starting Emacs, the =config.el= file is loaded.
small package I designed that essentially compiles the document you're
reading into working Emacs Lisp code for Emacs to load. The literate
package compiles this document by:
- concatenating all the Emacs Lisp blocks present in this document
- writing it to =config.el=,
Then, when starting Emacs, this =config.el= file is loaded.
This allows the document to act as both /source code/ and
/documentation/ at once. Pretty cool, right? This style of coding is
called /literate programming/. Donald Knuth
The prose is completely ignored in the final product, so I can wax
poetically about anything to my hearts content. This allows the
document to act as both /source code/ and /documentation/ at once.
Pretty cool, right? This style of coding is called /literate
programming/. Donald Knuth
[[https://en.wikipedia.org/wiki/Literate_programming][really liked]]
the idea and I see why.
Some details about the configuration:
+ The ordering of sections is relevant: packages defined earlier can
Some details about how my project while you'r p
- The ordering of sections is relevant: packages defined earlier can
be utilised by later packages
+ Sections tagged with =WAIT= are not compiled into the final document
- Sections tagged with =WAIT= are not compiled into the final document
(using :PROPERTIES:), usually with some explanation.
+ Some sections are essentially blog posts, so you may just want to
read the tangled output via ~(org-babel-tangle)~
- Some sections are essentially blog posts, so you may just want to
read the tangled output via ~(org-babel-tangle)~ and going to
[[file:config.el]].
* Basics
Let's setup a few absolute essentials:
+ My name and mail address
+ File encoding (no "\r" characters at the end of lines, please)
+ Where to store backup files (~backup-directory-alist~)
+ Auto refresh buffers when a change occurs (~auto-revert-mode~)
+ Yes or no questions are less painful (~y-or-n-p~)
+ Make the "kill ring" work seamlessly with the clipboard
+ Deleting files or directories "trashes" them instead
+ ... but when using ~tramp~ on remote machines, don't try to trash
the file to the local machine trash!!!
+ Font size based on the machine
+ Disable mouse usage where possible
+ Ensure when compiling the Emacs configuration, we only get messages
- My name and mail address
- File encoding (no "\r" characters at the end of lines, please)
- Where to store backup files (~backup-directory-alist~)
- Auto refresh buffers when a change occurs (~auto-revert-mode~)
- Yes or no questions are less painful (~y-or-n-p~)
- Make the "kill ring" work seamlessly with the clipboard
- Deleting files or directories "trashes" them instead
- ... but when going on remote machines via [[info:tramp][tramp]],
don't try to trash the file to the local machine trash!
- Font size based on the machine
- Disable mouse usage where possible
- Ensure when compiling the Emacs configuration, we only get messages
for really bad stuff
#+begin_src emacs-lisp
@@ -108,11 +110,11 @@ Let's setup a few absolute essentials:
#+end_src
* Custom functionality and libraries
This is custom Lisp that I or someone else has written which I really
need to setup as early as possible as it's necessary throughout the
rest of the configuration.
need to setup ASAP due to how necessary it is throughout the rest of
the configuration.
** dash
Dash is an external library that provides a ton of Emacs Lisp
functions that make it a bit nicer to use.
functions that make the language a bit nicer to use.
#+begin_src emacs-lisp
(use-package dash
:straight t
@@ -137,28 +139,72 @@ lambda with the first form of the lambda being (INTERACTIVE)."
#+end_src
** Clean buffer list
If you've got a particularly long running Emacs instance, as I usually
do, sometimes you just want to clean all those scratch and temporary
buffers up. Here I define a function which kills all buffers except
for those which have a name in ~clean-buffers-keep~.
do, sometimes you want to clean it all up. Perhaps all of the buffers
or just the ones in your current project. Here I define a function
which allows you to do so - ~clean-buffers~.
By default, it will kill all buffers associated with the directory of
your current buffer. Using ~C-u~ will provide a list of directories
for buffers available, which you can select from. ~C-u C-u~ will kill
all buffers period.
Please note ~clean-buffers-keep~, which defines a list of buffers that
must be preserved in any form of the operation above.
#+begin_src emacs-lisp
(defconst clean-buffers-keep
(list "config.org" "*scratch*"
"*dashboard*" "*Messages*"
"*Warnings*" "*eshell*"
"*ChatGPT*")
(list "*scratch*" "*dashboard*"
"*Messages*" "*Warnings*"
"*eshell*" "*ChatGPT*")
"List of buffer names to preserve.")
(defun clean-buffers ()
(defun --get-dir-or-project-dir (buffer)
(with-current-buffer buffer
(expand-file-name
(if (project-current)
(project-root (project-current))
default-directory))))
(defun --make-clean-buffer-alist ()
(cl-loop with assoc-list = nil
for buffer in (buffer-list)
for dir = (--get-dir-or-project-dir buffer)
if (assoc dir assoc-list #'string=)
do (setf (cdr (assoc dir assoc-list #'string=))
(cons buffer (cdr (assoc dir assoc-list #'string=))))
else do (setf assoc-list (cons (list dir buffer) assoc-list))
finally (return assoc-list)))
(defun clean-buffers (&optional arg)
"Kill all buffers except any with names in CLEAN-BUFFERS-KEEP."
(interactive)
(let ((should-not-kill
#'(lambda (buf)
(member (buffer-name buf)
clean-buffers-keep))))
(->> (buffer-list)
(cl-remove-if should-not-kill)
(mapc #'kill-buffer))))
(interactive "P")
(let ((buffer-alist (--make-clean-buffer-alist))
(items nil)
(should-not-kill
#'(lambda (buf) (member (buffer-name buf) clean-buffers-keep))))
(cond
((null arg)
(let ((choice (completing-read "Choose directory to kill: "
(mapcar #'car buffer-alist)
nil t)))
(setq items (cdr (assoc choice buffer-alist #'string=)))))
((and (listp arg)
(eq 4 (car arg)))
(setq items
(thread-first (current-buffer)
(--get-dir-or-project-dir )
(assoc buffer-alist #'string=)
(cdr))))
((and (listp arg)
(eq 16 (car arg)))
(setq items (buffer-list))))
(message "[clean-buffers]: Cleaning %d buffers" (length items))
(if items
(thread-last items
(cl-remove-if should-not-kill)
(mapc #'kill-buffer)))))
#+end_src
** Custom window management
Emacs has a window management system unlike any other piece of
@@ -270,6 +316,28 @@ the PATH variable with the shell to avoid any silly issues.
(when (member window-system '(mac ns x))
(exec-path-from-shell-initialize)))
#+end_src
** Reset font size
Font size is best left unfixed: depending on the display size and the
machine, I will usually need to adjust it so it looks just right.
This function sets the font size using both those variables. It is
also added to `enable-theme-functions` such that loading a theme will
forcefully adjust the font size.
#+begin_src emacs-lisp
(defvar +oreo/font-size-alist
'((1920 140)
(2560 160)))
(defun +oreo/font-reset (&optional _)
(let ((font-size (or (car (alist-get (display-pixel-width) +oreo/font-size-alist))
(cadar +oreo/font-size-alist))))
(set-face-attribute 'default nil :height font-size)
(set-face-attribute 'mode-line nil :height font-size)))
(add-to-list 'enable-theme-functions #'+oreo/font-reset)
(add-to-list 'after-make-frame-functions #'+oreo/font-reset)
#+end_src
* Essential packages
External and internal packages absolutely necessary for the rest of
this configuration.
@@ -1106,8 +1174,8 @@ When scrolling, editors generally try to keep the cursor on screen.
Emacs has some variables which ensure the cursor is a certain number
of lines above the bottom of the screen and below the top of the
screen when scrolling. Here I set the margin to 8 (so it'll start
correcting at 8) and scroll-conservatively to the same value so it'll
keep the cursor centred.
correcting at 8 lines) and scroll-conservatively to the same value so
it'll keep the cursor centred.
I also setup the ~pixel-scroll-mode~ to make scrolling nicer looking.
@@ -1560,8 +1628,8 @@ Here I setup dired with a few niceties
:general
(nmmap
:keymaps 'dired-mode-map
"SPC" nil
"SPC ," nil
"SPC" #'nil
"SPC ," #'nil
"M-k" #'dired-prev-subdir
"M-j" #'dired-next-subdir
"q" #'quit-window
@@ -1593,7 +1661,7 @@ Here I setup dired with a few niceties
"&" #'dired-do-async-shell-command
"{" #'dired-prev-marked-file
"}" #'dired-next-marked-file
"%" nil
"%" #'nil
"%u" #'dired-upcase
"%l" #'dired-downcase
"%d" #'dired-flag-files-regexp
@@ -1605,7 +1673,7 @@ Here I setup dired with a few niceties
"%R" #'dired-do-rename-regexp
"%S" #'dired-do-symlink-regexp
"%&" #'dired-flag-garbage-files
"*" nil
"*" #'nil
"**" #'dired-mark-executables
"*/" #'dired-mark-directories
"*@" #'dired-mark-symlinks
@@ -1677,7 +1745,7 @@ Here I setup dired with a few niceties
(dired-mark-directories nil)
(let* ((subdirs-inserted (mapcar #'car dired-subdir-alist))
(subdirs-available (mapcar #'(lambda (x) (concat x "/"))
(dired-get-marked-files))))
(dired-get-marked-files))))
(dired-unmark-all-marks)
(cl-remove-if #'(lambda (f) (member f subdirs-inserted)) subdirs-available)))
@@ -2327,9 +2395,8 @@ playing.
:general
(app-leader
"e" #'empv-hydra/body)
:init
(setq empv-audio-dir (list (expand-file-name "~/Media/audio"))
(setq empv-audio-dir (list (expand-file-name "~/Media/music"))
empv-video-dir (list (expand-file-name "~/Media/videos")
(expand-file-name "~/Media/anime"))
empv-playlist-dir (expand-file-name "~/Media/playlists")
@@ -2862,73 +2929,41 @@ apply diffs - here I configure a small subset.
"RET" #'diff-goto-source))
#+end_src
* Languages
For a variety of (programming) languages Emacs comes with default
modes but this configures them as well as pulls any modes Emacs
doesn't come with.
Emacs comes with support for many different types of
programming/markup languages. Here I configure the ones I use, as
well as some external packages to increase the level of support.
** Org mode
Org is, at its most basic, a markup language. =org-mode= is a major
mode for Emacs to interpret org buffers. org-mode provides a lot of
capabilities, some are:
+ A complete table based spreadsheet system, with formulas (including
Org is, at its most basic, a markup language. But to call it /just/ a
markup language is a major understatement. org-mode, the major mode
for Org files in Emacs, provides a lot of capabilities, such as:
- Code blocks with proper syntax highlighting and the ability to edit
them in the language mode
- Code block evaluation
- Export of code blocks to a variety of formats
- Export of code blocks to a separate file (so called "tangling",
which is used extensively in
[[file:elisp/literate.el][literate.el]] with this very document to
make my Emacs configuration work)
- Task management
- TODO system to mark the progress on a task, with the nesting of
headings allowing for non-trivial dependency management
- Feature complete scheduling system with [[*Calendar][calendar]]
integration
- A clock-in system to time tasks
- Links to a variety of formats:
- Websites (via http or https)
- FTP
- SSH
- Files (even to a specific line)
- Info pages
- A complete table based spreadsheet system, with formulas (including
[[*Calculator][calc-mode]] integration)
+ Code blocks with proper syntax highlighting and editing experience
+ Evaluation
+ Export of code blocks to a variety of formats
+ Export of code blocks to a code file (so called "tangling", which
is what occurs in this document)
+ Feature complete scheduling system with [[*Calendar][calendar]]
integration
+ A clock-in system to time tasks
+ TODO system
+ Export to a variety of formats or make your own export engine using
- Export to a variety of formats or make your own export engine using
the org AST.
+ Inline $\LaTeX$, with the ability to render the fragments on
demand within the buffer
+ Links to a variety of formats:
+ Websites (via http or https)
+ FTP
+ SSH
+ Files (even to a specific line)
+ Info pages
- Inline $\LaTeX$, with the ability to render them on demand
I'd argue this is a bit more than a markup language. Like
This is but a portion of what Org is capable of; like
[[*Magit][Magit]], some use Emacs just for this system.
*** Org Latex
Org mode has deep integration with latex, can export to PDF and even
display latex fragments in the document directly. I setup the
pdf-process, code listing options via minted and the format options
for latex fragments.
#+begin_src emacs-lisp
(use-package org
:defer t
:init
(setq org-format-latex-options
'(:foreground default :background "Transparent" :scale 1.5
:html-foreground "Black" :html-background "Transparent"
:html-scale 1.0 :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))
org-latex-src-block-backend 'minted
org-latex-minted-langs '((emacs-lisp "common-lisp")
(ledger "text")
(cc "c++")
(cperl "perl")
(shell-script "bash")
(caml "ocaml"))
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
(list (concat "latexmk -f -bibtex -pdf "
"-shell-escape -%latex -interaction=nonstopmode "
"-output-directory=%o %f"))
org-latex-minted-options
'(("style" "colorful")
("linenos")
("frame" "single")
("mathescape")
("fontfamily" "courier")
("samepage" "false")
("breaklines" "true")
("breakanywhere" "true"))))
#+end_src
*** Org Variables
Tons of variables for org-mode, including a ton of latex ones. Can't
really explain because it sets up quite a lot of local stuff. Look at
@@ -2977,9 +3012,10 @@ felt good. Doom Emacs was very helpful here.
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(lisp . t)
(shell . t)
(python . t))))
(lisp . t)
(shell . t)
(python . t)
(C . t))))
#+end_src
*** Org Functionality
Hooks, prettify-symbols and records for auto insertion.
@@ -2992,6 +3028,9 @@ Hooks, prettify-symbols and records for auto insertion.
:display
("\\*Org Src.*"
(display-buffer-same-window))
("\\*Org Links\\*"
(display-buffer-no-window)
(allow-no-window . t))
:auto-insert
(("\\.org\\'" . "Org skeleton")
"Enter title: "
@@ -3036,7 +3075,7 @@ write the code.
"d" #'org-deadline
"s" #'org-schedule
"t" #'org-todo
"r" #'org-list-repair
"r" #'org-refile
"," #'org-priority
"n" #'org-narrow-to-subtree
"w" #'widen
@@ -3047,7 +3086,7 @@ write the code.
"o" #'org-edit-special
"T" #'org-babel-tangle
"S" #'org-property-action
"R" #'org-refile
"R" #'org-list-repair
"O" #'org-open-at-point-global)
(local-leader
@@ -3087,8 +3126,10 @@ a very tidy way to manage your time.
org-agenda-start-with-entry-text-mode nil
org-agenda-span 'week
org-agenda-custom-commands
'(("n" "Agenda and all TODOs" ((agenda "") (alltodo "")))
("w" todo "WIP")))
'(("n" "Agenda (no reading)" ((agenda "-reading") (alltodo "")))
("r" "Reading" agenda ""
((org-agenda-skip-function
(org-agenda-skip-entry-if 'regexp "reading.*"))))))
:config
(evil-set-initial-state 'org-agenda-mode 'normal)
:general
@@ -3152,6 +3193,76 @@ todo file directly.
"ZR" #'org-capture-refile
"ZQ" #'org-capture-kill))
#+end_src
*** Org Latex
Org mode has deep integration with latex, can export to PDF and even
display latex fragments in the document directly. I setup the
pdf-process, code listing options via minted and the format options
for latex fragments.
#+begin_src emacs-lisp
(use-package org
:defer t
:init
(setq org-format-latex-options
'(:foreground default :background "Transparent" :scale 1.5
:html-foreground "Black" :html-background "Transparent"
:html-scale 1.0 :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))
org-latex-src-block-backend 'minted
org-latex-minted-langs '((emacs-lisp "common-lisp")
(ledger "text")
(cc "c++")
(cperl "perl")
(shell-script "bash")
(caml "ocaml"))
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
(list (concat "latexmk -f -bibtex -pdf "
"-shell-escape -%latex -interaction=nonstopmode "
"-output-directory=%o %f"))
org-latex-minted-options
'(("style" "colorful")
("linenos")
("frame" "single")
("mathescape")
("fontfamily" "courier")
("samepage" "false")
("breaklines" "true")
("breakanywhere" "true"))))
#+end_src
*** Org Message
Org message allows for the use of org mode when composing mails,
generating HTML multipart emails. This integrates the WYSIWYG
experience with mail in Emacs while also providing powerful text
features with basically no learning curve (as long as you've already
learnt the basics of org).
#+begin_src emacs-lisp
(use-package org-msg
:straight t
:hook
(message-mode-hook . org-msg-mode)
(notmuch-message-mode-hook . org-msg-mode)
:config
(setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil \\n:t tex:dvipng"
org-msg-greeting-name-limit 3)
(add-to-list
'org-msg-enforce-css
'(img latex-fragment-inline
((transform . ,(format "translateY(-1px) scale(%.3f)"
(/ 1.0 (if (boundp 'preview-scale)
preview-scale 1.4))))
(margin . "0 -0.35em")))))
#+end_src
*** Org for Evil
Evil org for some nice bindings.
#+begin_src emacs-lisp
(use-package evil-org
:straight t
:defer t
:hook (org-mode-hook . evil-org-mode))
#+end_src
*** WAIT Org Clock-in
:PROPERTIES:
:header-args:emacs-lisp: :tangle no :results none
@@ -3191,40 +3302,6 @@ For bibliographic stuff in $\LaTeX$ export.
bibtex-completion-bibliography '("~/Text/bibliography.bib")
bibtex-completion-additional-search-fields '(keywords)))
#+end_src
*** Org Message
Org message allows for the use of org mode when composing mails,
generating HTML multipart emails. This integrates the WYSIWYG
experience with mail in Emacs while also providing powerful text
features with basically no learning curve (as long as you've already
learnt the basics of org).
#+begin_src emacs-lisp
(use-package org-msg
:straight t
:hook
(message-mode-hook . org-msg-mode)
(notmuch-message-mode-hook . org-msg-mode)
:config
(setq org-msg-options "html-postamble:nil H:5 num:nil ^:{} toc:nil author:nil email:nil \\n:t tex:dvipng"
org-msg-greeting-name-limit 3)
(add-to-list
'org-msg-enforce-css
'(img latex-fragment-inline
((transform . ,(format "translateY(-1px) scale(%.3f)"
(/ 1.0 (if (boundp 'preview-scale)
preview-scale 1.4))))
(margin . "0 -0.35em")))))
#+end_src
*** Org for Evil
Evil org for some nice bindings.
#+begin_src emacs-lisp
(use-package evil-org
:straight t
:defer t
:hook (org-mode-hook . evil-org-mode))
#+end_src
** Makefile
Defines an auto-insert for Makefiles. Assumes C but it's very easy to
change it for C++.
@@ -3310,7 +3387,6 @@ Tons of stuff, namely:
+ Some keybindings to make evil statement movement easy
+ Lots of pretty symbols
+ Indenting options and a nice (for me) code style for C
+ Auto inserts to get a C file going
#+begin_src emacs-lisp
(use-package cc-mode
@@ -3330,46 +3406,6 @@ Tons of stuff, namely:
c-default-style '((other . "user")))
(add-hook 'c-mode-hook (proc (c-toggle-comment-style -1)))
(add-hook 'c++-mode-hook (proc (c-toggle-comment-style -1)))
(defun +cc/copyright-notice ()
(let* ((lines (split-string (+license/copyright-notice) "\n"))
(copyright-line (car lines))
(rest (cdr lines)))
(concat
"* "
copyright-line
"\n"
(mapconcat
#'(lambda (x)
(if (string= x "")
""
(concat " * " x)))
rest
"\n"))))
:auto-insert
(("\\.c\\'" . "C skeleton")
""
"/" (+cc/copyright-notice) "\n\n"
" * Created: " (format-time-string "%Y-%m-%d") "\n"
" * Description: " _ "\n"
" */\n"
"\n")
(("\\.cpp\\'" "C++ skeleton")
""
"/" (+cc/copyright-notice) "\n\n"
" * Created: " (format-time-string "%Y-%m-%d") "\n"
" * Description: " _ "\n"
" */\n"
"\n")
(("\\.\\([Hh]\\|hh\\|hpp\\|hxx\\|h\\+\\+\\)\\'" . "C / C++ header")
(replace-regexp-in-string "[^A-Z0-9]" "_"
(string-replace "+" "P"
(upcase
(file-name-nondirectory buffer-file-name))))
"/" (+cc/copyright-notice) "\n\n"
" * Created: " (format-time-string "%Y-%m-%d") "\n"
" * Description: " _ "\n"
" */\n\n"
"#ifndef " str n "#define " str "\n\n" "\n\n#endif")
:config
(c-add-style
"user"
@@ -3389,6 +3425,65 @@ Tons of stuff, namely:
(label . 0)
(statement-cont . +)))))
#+end_src
*** cc auto insert
This is a generic auto-insert template for C/C++ files.
#+begin_src emacs-lisp
(use-package cc-mode
:defer t
:init
(defun +cc/copyright-notice ()
(let* ((lines (split-string (+license/copyright-notice) "\n"))
(copyright-line (car lines))
(rest (cdr lines)))
(concat
"* "
copyright-line
"\n"
(mapconcat
#'(lambda (x)
(if (string= x "")
""
(concat " * " x)))
rest
"\n"))))
:auto-insert
(("\\.c\\'" . "C skeleton")
""
"/* " (file-name-nondirectory (buffer-file-name)) ": " _ "\n"
" * Created: " (format-time-string "%Y-%m-%d") "\n"
" * Author: " user-full-name "\n"
" * License: See end of file\n"
" * Commentary:\n"
" */\n"
"\n\n"
"/" (+cc/copyright-notice) "\n\n*/")
(("\\.cpp\\'" "C++ skeleton")
""
"/* " (file-name-nondirectory (buffer-file-name)) ": " _ "\n"
" * Created: " (format-time-string "%Y-%m-%d") "\n"
" * Author: " user-full-name "\n"
" * License: See end of file\n"
" * Commentary:\n"
" */\n"
"\n\n"
"/" (+cc/copyright-notice) "\n\n*/")
(("\\.\\([Hh]\\|hh\\|hpp\\|hxx\\|h\\+\\+\\)\\'" . "C / C++ header")
(replace-regexp-in-string "[^A-Z0-9]" "_"
(string-replace "+" "P"
(upcase
(file-name-nondirectory buffer-file-name))))
""
"/* " (file-name-nondirectory (buffer-file-name)) ": " _ "\n"
" * Created: " (format-time-string "%Y-%m-%d") "\n"
" * Author: " user-full-name "\n"
" * License: See end of file\n"
" * Commentary:\n"
" */\n"
"\n\n"
"#ifndef " str n "#define " str "\n\n" "\n\n#endif\n"
"/" (+cc/copyright-notice) "\n\n*/"))
#+end_src
*** Clang format
clang-format is a program that formats C/C++ files. It's highly
configurable and quite fast. I have a root configuration in my
@@ -3442,7 +3537,7 @@ a regular expression which captures file names and digits
:config
(add-to-list 'compilation-error-regexp-alist-alist
`(fsan ,(rx (and
line-start " #" digit " 0x" (1+ hex) " in "
line-start " #" (1+ digit) " 0x" (1+ hex) " in "
(1+ (or word "_")) " "
(group (seq (* any) (or ".c" ".cpp" ".h" ".hpp"))) ":"
(group (+ digit))))
@@ -3671,7 +3766,7 @@ Emmet for super speed code writing.
"M-j" #'emmet-next-edit-point
"M-k" #'emmet-prev-edit-point))
#+end_src
*** HTML Auto insert
*** HTML auto insert
An auto-insert for HTML buffers, which just adds some nice stuff.
#+begin_src emacs-lisp

View File

@@ -2,6 +2,6 @@
"NeoSolarized": { "branch": "master", "commit": "b94b1a9ad51e2de015266f10fdc6e142f97bd617" },
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope.nvim": { "branch": "master", "commit": "0294ae3eafe662c438addb8692d9c98ef73a983e" },
"telescope.nvim": { "branch": "master", "commit": "3a12a853ebf21ec1cce9a92290e3013f8ae75f02" },
"vim-tmux-navigator": { "branch": "master", "commit": "c45243dc1f32ac6bcf6068e5300f3b2b237e576a" }
}

View File

@@ -81,10 +81,10 @@ super + shift + Escape
# Media
super + F{6,7,8}
playerctl --player=spotify {previous,play-pause,next};
playerctl --player=mpv {previous,play-pause,next};
XF86Audio{Prev,Play,Next}
playerctl --player=spotify {previous,play-pause,next};
playerctl --player=mpv {previous,play-pause,next};
XF86Audio{Lower,Raise}Volume
kill -42 $(pidof dwmblocks); \

View File

@@ -13,9 +13,7 @@ if (len(argv) > 1):
if (len(argv) > 2):
name = argv[2]
duration *= 3600
print("Starting alarm '%s'" % name, "of duration %ds" % duration)
run(["notify-send", f"Starting alarm {name}, duration of {duration}s"])
current = time()
end = current + duration

View File

@@ -0,0 +1,4 @@
#!/usr/bin/env sh
mem_left_kb=$(awk -F'[ ]*' '/Dirty/ { print $2 }' /proc/meminfo)
echo "$(date)": $(echo "$mem_left_kb / 1000" | bc -l)

64
Scripts/.local/scripts/kgrep Executable file
View File

@@ -0,0 +1,64 @@
#!/usr/bin/env python3
from dataclasses import dataclass
from typing import List, Dict
from subprocess import run, PIPE
def strip_comments(line: str):
if (line[0] == ';'):
return ""
elif (comment_start := line.find("#")) >= 0:
line = line[:comment_start]
return line.rstrip()
def parse_keybind(lines: List[str]):
keybind = lines[0]
commands = []
end = len(lines) - 1
for i, line in enumerate(lines[1:]):
if line.startswith(" "):
commands.append(line)
else:
end = i
break
end += 1
return keybind, commands, lines[end:]
def parse_all_keybinds(lines: list[str]) -> Dict[str, list[str]]:
binds = dict()
while len(lines) != 0:
binding, commands, lines = parse_keybind(lines)
binds[binding] = commands
return binds
def get_config_data(filepath: str):
with open(filepath, "r") as fp:
lines = fp.readlines()
lines = map(strip_comments, lines)
lines = filter(lambda x : x != "", lines)
bindings = parse_all_keybinds(list(lines))
return bindings
def dmenu(prompt: str, items: list) -> str:
return run(["dmenu", "-p", "Choose binding: "],
input="\n".join(items),
capture_output=True,
text=True).stdout.strip()
def get_keybind(keybinds: Dict[str, list[str]]) -> str:
return dmenu("Choose binding: ", list(keybinds.keys())).replace("\n", "")
def get_command(keybinds: Dict[str, list[str]]) -> str:
reverse_map = dict()
for key in keybinds:
value = keybinds[key]
if reverse_map.get(value) is not None:
continue
reverse_map[value] = key
return dmenu("Choose binding: ", list(reverse_map.keys())).replace("\n", "")
bindings = get_config_data("/home/oreo/.config/sxhkd/sxhkdrc")
choice = get_command(bindings)
print(choice, bindings[choice])

View File

@@ -4,4 +4,4 @@ prev=$(notmuch count)
mbsync -a
notmuch new
new=$(notmuch count)
notify-send "mail_fetch: Fetched $(echo $new - $prev | bc -l) mail"
notify-send "Fetched $(echo $new - $prev | bc -l) mail"

View File

@@ -4,6 +4,7 @@ processes="st btop
emacsclient -c -a emacs
$HOME/.local/scripts/browser
steam
discord
spotify"

View File

@@ -1,8 +1,9 @@
#!/usr/bin/env sh
controller=$(bluetoothctl list)
devices=$(bluetoothctl devices Connected | awk '{print $2}')
if [ -z "$devices" ]
if [ -z "$devices" ] || [ -z "$controller" ]
then
echo ''
else

View File

@@ -1,4 +1,3 @@
#!/usr/bin/env sh
data=$(sensors | awk -F'+' '/Tctl/ { gsub(/[ \t]+$/, "", $2); print $2 }')
echo "㊋ $data"
echo "㊋ $(sensors | grep "Core" | sed 's/Core [0-9]:[ ]*+//;s/C.*//' | sort -r | head -1)C"

View File

@@ -3,7 +3,7 @@ Description=Run mail sync every hour
[Timer]
OnBootSec=1min
OnUnitActiveSec=3600
OnUnitActiveSec=1800
Unit=mail.service
[Install]