]> git.armaanb.net Git - config.org.git/blobdiff - config.org
Add space
[config.org.git] / config.org
index c14d9a2b4628597b5187305ba4cf46becb5dcca3..ba059c0e87b98b8f34f1846e1b4d709371209363 100644 (file)
@@ -15,9 +15,7 @@ Another important choice has been to integrate Emacs into a large part of my com
 Lastly, I use Evil mode. I think modal keybindings are simple and more ergonomic than standard Emacs style, and Vim keybindings are what I'm comfortable with and are pervasive throughout computing.
 ** TODOs
 *** TODO Turn keybinding and hook declarations into use-package declarations where possible
-*** TODO Put configs with passwords in here with some kind of authentication
-- Offlineimap
-- irc.el
+*** TODO Include offlineimap config
 ** License
 Released under the [[https://opensource.org/licenses/MIT][MIT license]] by Armaan Bhojwani, 2021. Note that many snippets are taken from online, and other sources, who are credited for their work at the snippet.
 * Package management
@@ -269,8 +267,10 @@ Add back C-a/C-x
     (add-to-list 'org-structure-template-alist '("za" . "src conf :tangle ~/.config/zathura/zathurarc"))
     (add-to-list 'org-structure-template-alist '("ff1" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css"))
     (add-to-list 'org-structure-template-alist '("ff2" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css"))
-    (add-to-list 'org-structure-template-alist '("xr" . "src conf :tangle ~/.Xresources")
-    (add-to-list 'org-structure-template-alist '("tm" . "src conf :tangle ~/.tmux.conf")))
+    (add-to-list 'org-structure-template-alist '("xr" . "src conf :tangle ~/.Xresources"))
+    (add-to-list 'org-structure-template-alist '("tm" . "src conf :tangle ~/.tmux.conf"))
+    (add-to-list 'org-structure-template-alist '("gp" . "src conf :tangle ~/.gnupg/gpg.conf"))
+    (add-to-list 'org-structure-template-alist '("ag" . "src conf :tangle ~/.gnupg/gpg-agent.conf")))
 #+end_src
 * Autocompletion
 ** Ivy
@@ -314,7 +314,7 @@ Better search utility.
 #+begin_src emacs-lisp
   (use-package swiper)
 #+end_src
-* EmacsOS
+* Emacs OS
 ** RSS
 Use elfeed for RSS. I have another file with all the feeds in it.
 #+begin_src emacs-lisp
@@ -357,6 +357,7 @@ Contexts are a not very well known feature of mu4e that makes it super easy to m
           mu4e-confirm-quit nil
           mu4e-view-use-gnus t
           mail-user-agent 'mu4e-user-agent
+          mail-context-policy 'pick-first
           mu4e-contexts
           `( ,(make-mu4e-context
                :name "school"
@@ -395,8 +396,9 @@ Contexts are a not very well known feature of mu4e that makes it super easy to m
                          :key ?b))
     :hook ((mu4e-compose-mode . flyspell-mode)
            (mu4e-compose-mode . auto-fill-mode)
-           (mu4e-view-mode-hook . turn-on-visual-line-mode)))
-
+           (mu4e-view-mode-hook . turn-on-visual-line-mode)
+           (message-send-hook . (lambda () (unless (yes-or-no-p "Ya sure 'bout that?")
+                                             (signal 'quit nil))))))
 #+end_src
 Discourage Gnus from displaying HTML emails
 #+begin_src emacs-lisp
@@ -438,53 +440,96 @@ Some EWW enhancements.
     :bind (("C-c w" . eww))
     :hook (eww-after-render-hook prot-eww--rename-buffer))
 #+end_src
-*** Better entrypoint
+*** Keybinding
 #+begin_src emacs-lisp
-  ;; From https://protesilaos.com/dotemacs/
-  (defun prot-eww-browse-dwim (url &optional arg)
-    "Visit a URL, maybe from `eww-prompt-history', with completion.
-
-  With optional prefix ARG (\\[universal-argument]) open URL in a
-  new eww buffer.
-
-  If URL does not look like a valid link, run a web query using
-  `eww-search-prefix'.
-
-  When called from an eww buffer, provide the current link as
-  initial input."
-    (interactive
-     (list
-      (completing-read "Query:" eww-prompt-history
-                       nil nil (plist-get eww-data :url) 'eww-prompt-history)
-      current-prefix-arg))
-    (eww url (if arg 4 nil)))
-
-  (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
+  (global-set-key (kbd "C-c w") 'eww)
 #+end_src
 ** IRC
-#+begin_src emacs-lisp
-  (use-package erc
-    :straight (:type built-in)
+Circe is a really nice IRC client, that claims to be above RCIRC and below ERC in terms of features. ERC felt a bit messy and finicky to me, and Circe has all the features that I need. This setup gets the password for my bouncer (Pounce) instances via my =~/.authinfo.gpg= file.
+#+begin_src emacs-lisp
+  (defun fetch-password (&rest params)
+    (require 'auth-source)
+    (let ((match (car (apply 'auth-source-search params))))
+      (if match
+          (let ((secret (plist-get match :secret)))
+            (if (functionp secret)
+                (funcall secret)
+              secret))
+        (error "Password not found for %S" params))))
+
+  (use-package circe
     :config
-    (load "~/.emacs.d/irc.el")
-    (erc-notifications-mode 1)
-    (erc-smiley-disable)
-    :custom (erc-prompt-for-password . nil))
+    (enable-lui-track)
+    (enable-circe-color-nicks)
+    (circe "libera")
+    (circe "oftc")
+    (circe "tilde")
+    (setq circe-networks '(("libera"
+                            :host "irc.armaanb.net"
+                            :nick "emacs"
+                            :user "emacs"
+                            :use-tls t
+                            :port "6698"
+                            :pass (lambda (null) (fetch-password
+                                                  :login "emacs"
+                                                  :machine "irc.armaanb.net"
+                                                  :port 6698)))
+                           ("oftc"
+                            :host "irc.armaanb.net"
+                            :nick "emacs"
+                            :user "emacs"
+                            :use-tls t
+                            :port "6699"
+                            :pass (lambda (null) (fetch-password
+                                                  :login "emacs"
+                                                  :machine "irc.armaanb.net"
+                                                  :port 6699)))
+                           ("tilde"
+                            :host "irc.armaanb.net"
+                            :nick "emacs"
+                            :user "emacs"
+                            :use-tls t
+                            :port "6696"
+                            :pass (lambda (null) (fetch-password
+                                                  :login "emacs"
+                                                  :machine "irc.armaanb.net"
+                                                  :port 6696)))
+                           ))
+    :custom (circe-default-part-message "goodbye!")
+    :bind (:map circe-mode-map ("C-c C-r" . circe-reconnect-all)))
+#+end_src
+** Calendar
+#+begin_src emacs-lisp
+  (defun sync-calendar ()
+    "Sync calendars with vdirsyncer"
+    (interactive)
+    (shell-command "vdirsyncer -vcritical sync"))
 
-  (use-package erc-hl-nicks
-    :config (erc-hl-nicks-mode 1))
+  (use-package calfw
+    :bind (:map cfw:calendar-mode-map ("C-S-u" . sync-calendar)))
+  (use-package calfw-ical)
+  (use-package calfw-org)
 
-  (defun acheam-irc ()
-    "Connect to irc"
+  (defun acheam-calendar ()
+    "Open calendars"
     (interactive)
-    (erc-tls :server "irc.armaanb.net" :nick "emacs"))
+    (cfw:open-calendar-buffer
+     :contents-sources (list
+                        (cfw:org-create-source "Green")
+                        (cfw:ical-create-source
+                         "Personal"
+                         "~/.local/share/vdirsyncer/mailbox/Y2FsOi8vMC8zMQ.ics"
+                         "Gray")
+                        (cfw:ical-create-source
+                         "Personal"
+                         "~/.local/share/vdirsyncer/mailbox/Y2FsOi8vMC8zMQ.ics"
+                         "Red")
+                        (cfw:ical-create-source
+                         "School"
+                         "~/.local/share/vdirsyncer/school/abhojwani22@nobles.edu.ics"
+                         "Cyan"))))
 
-  (acheam-irc)
-#+end_src
-** Emacs Anywhere
-Use Emacs globally. Use the Emacs daemon and bind a key in your wm to =emacsclient --eval "(emacs-everywhere)"=.
-#+begin_src emacs-lisp
-  (use-package emacs-everywhere)
+  (global-set-key (kbd "C-c c") 'acheam-calendar)
 #+end_src
 * Emacs IDE
 ** Code cleanup
@@ -563,6 +608,25 @@ Use Emacs globally. Use the Emacs daemon and bind a key in your wm to =emacsclie
     :straight (git-email :repo "https://git.sr.ht/~yoctocell/git-email")
     :config (git-email-piem-mode))
 #+end_src
+** Java
+*** Evaluate current buffer
+Stolen from https://stackoverflow.com/questions/19953924/how-do-you-run-java-codes-in-emacs
+#+begin_src emacs-lisp
+  (defun java-eval-buffer ()
+    "run current program (that requires no input)"
+    (interactive)
+    (let* ((source (file-name-nondirectory buffer-file-name))
+           (out    (file-name-sans-extension source))
+           (class  (concat out ".class")))
+      (save-buffer)
+      (shell-command (format "rm -f %s && javac %s" class source))
+      (if (file-exists-p class)
+          (shell-command (format "java %s" out) "*scratch*")
+        (progn
+          (set (make-local-variable 'compile-command)
+               (format "javac %s" source))
+          (command-execute 'compile)))))
+#+end_src
 * General text editing
 ** Indentation
 Indent after every change.
@@ -708,6 +772,14 @@ No more clogging up init.el.
               "0c" '0x0-upload-kill-ring
               "0p" '0x0-upload-popup))
 #+end_src
+** Automatically clean buffers
+#+begin_src emacs-lisp
+  ;; Don't kill Circe buffers
+  (add-to-list 'clean-buffer-list-kill-never-regexps (lambda (buffer-name)
+                                                       (with-current-buffer buffer-name
+                                                         (derived-mode-p 'lui-mode))))
+  (midnight-mode)
+#+end_src
 * Tangles
 ** Spectrwm
 *** General settings
@@ -768,16 +840,16 @@ No more clogging up init.el.
 **** Programs
 #+begin_src conf :tangle ~/.spectrwm.conf
   program[email] = emacsclient -c --eval "(mu4e)"
-  program[irc] = emacsclient -c --eval '(switch-to-buffer "irc.armaanb.net:6697")'
+  program[irc] = emacsclient -c --eval '(switch-to-buffer "irc.armaanb.net:6698")'
+  program[rss] = emacsclient -c --eval '(elfeed)'
   program[emacs] = emacsclient -c
   program[firefox] = firefox
   program[calc] = st -e because -l
-  program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
 
   bind[email] = MOD+Control+1
   bind[irc] = MOD+Control+2
-  bind[firefox] = MOD+Control+3
-  bind[emacs-anywhere] = MOD+Control+4
+  bind[rss] = MOD+Control+3
+  bind[firefox] = MOD+Control+4
   bind[calc] = MOD+Control+5
   bind[emacs] = MOD+Control+Return
 #+end_src
@@ -912,12 +984,11 @@ No more clogging up init.el.
   alias grep='grep -in --color=auto'
   alias mkdir='mkdir -pv'
   alias lanex='java -jar ~/.local/share/lxc/lanxchange.jar'
-  alias vim=$EDITOR
-  alias emacs=$EDITOR
+  emacs() { $EDITOR "$@" & }
+  alias vim="emacs"
 #+end_src
 **** System management
 #+begin_src shell :tangle ~/.config/ash/ashrc
-  alias pkill='pkill -i'
   alias crontab='crontab-argh'
   alias sudo='doas'
   alias pasu='git -C ~/.password-store push'
@@ -1166,6 +1237,7 @@ Lightweight notification daemon.
   }
 #+end_src
 *** Black screen by default
+userChrome.css:
 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
   #main-window,
   #browser,
@@ -1180,6 +1252,8 @@ Lightweight notification daemon.
       color: #fff !important;
   }
 #+end_src
+
+userContent.css:
 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css
   @-moz-document url("about:home"), url("about:blank"), url("about:newtab") {
       body {
@@ -1188,8 +1262,7 @@ Lightweight notification daemon.
   }
 #+end_src
 ** Xresources
-*** Color scheme
-Modus operandi.
+Modus operandi theme.
 #+begin_src conf :tangle ~/.Xresources
   ! special
   ,*.foreground:   #ffffff
@@ -1228,25 +1301,24 @@ Modus operandi.
   ,*.color7:       #eeeeee
   ,*.color15:      #dddddd
 #+end_src
-*** Copy paste
-#+begin_src conf :tangle ~/.Xresources
-  xterm*VT100.Translations: #override \
-  Shift <KeyPress> Insert: insert-selection(CLIPBOARD) \n\
-  Ctrl Shift <Key>V:    insert-selection(CLIPBOARD) \n\
-  Ctrl Shift <Key>C:    copy-selection(CLIPBOARD) \n\
-  Ctrl <Btn1Up>: exec-formatted("xdg-open '%t'", PRIMARY)
-#+end_src
-*** Blink cursor
-#+begin_src conf :tangle ~/.Xresources
-  xterm*cursorBlink: true
-#+end_src
-*** Alt keys
-#+begin_src conf :tangle ~/.Xresources
-  XTerm*eightBitInput:   false
-  XTerm*eightBitOutput:  true
-#+end_src
 ** Tmux
 #+begin_src conf :tangle ~/.tmux.conf
   set -g status off
+  set -g mouse on
   set-window-option -g mode-keys vi
+  bind-key -T copy-mode-vi 'v' send -X begin-selection
+  bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
+#+end_src
+** GPG
+*** Config
+#+begin_src conf :tangle ~/.gnupg/gpg.conf
+  default-key 3C9ED82FFE788E4A
+  use-agent
+#+end_src
+*** Agent
+#+begin_src conf :tangle ~/.gnupg/gpg-agent.conf
+  pinentry-program /sbin/pinentry-gnome3
+  max-cache-ttl 600
+  default-cache-ttl 600
+  allow-emacs-pinentry
 #+end_src