emacs/eshell: restore mistakenly deleted custom eshell prompt
[~bandali/configs] / .emacs.d / init.el
index 0d2c850..04133fe 100644 (file)
@@ -1,6 +1,6 @@
-;;; init.el --- mab's emacs configuration -*- lexical-binding: t -*-
+;;; init.el --- bandali's emacs configuration -*- lexical-binding: t -*-
 
-;; Copyright (C) 2018-2019  Amin Bandali <mab@gnu.org>
+;; Copyright (C) 2018-2019  Amin Bandali <bandali@gnu.org>
 
 ;; This program is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 
 ;;; Commentary:
 
-;; Emacs configuration of Amin Bandali, computer scientist, free
-;; software activist, GNU maintainer & webmaster.  Packages are
-;; installed from GNU Guix, for purely functional and fully
-;; reproducible package management.  Before switching to GNU Guix,
-;; I used straight.el for package management, and before that, Borg.
+;; GNU Emacs configuration of Amin Bandali, computer scientist,
+;; Free Software activist, and GNU maintainer & webmaster.  Packages
+;; are installed through GNU Guix for a fully reproducible setup.
+;; Before switching to Guix, I used straight.el, and before that Borg.
 
 ;; Over the years, I've taken inspiration from configurations of many
 ;; great people.  Some that I can remember off the top of my head are:
@@ -55,7 +54,7 @@
 (defvar b/gc-cons-threshold gc-cons-threshold)
 (defvar b/gc-cons-percentage gc-cons-percentage)
 (defvar b/file-name-handler-alist file-name-handler-alist)
-(setq gc-cons-threshold (* 400 1024 1024)  ; 400 MiB
+(setq gc-cons-threshold (* 30 1024 1024)  ; 30 MiB
       gc-cons-percentage 0.6
       file-name-handler-alist nil
       ;; sidesteps a bug when profiling with esup
   (setq b/emacs-initialized     t
         gc-cons-threshold       b/gc-cons-threshold
         gc-cons-percentage      b/gc-cons-percentage
-        file-name-handler-alist b/file-name-handler-alist))
+        file-name-handler-alist b/file-name-handler-alist)
+  (with-eval-after-load 'exwm-workspace
+    (setq-default
+     mode-line-format
+     (append
+      mode-line-format
+      '((:eval
+         (format
+          "[%s]" (number-to-string
+                  exwm-workspace-current-index))))))))
 (add-hook 'after-init-hook #'b/post-init)
 
 ;; increase number of lines kept in *Messages* log
@@ -82,7 +90,7 @@
 ;;; whoami
 
 (setq user-full-name "Amin Bandali"
-      user-mail-address "mab@gnu.org")
+      user-mail-address "bandali@gnu.org")
 
 \f
 ;;; comment macro
   (with-demoted-errors
       (load (b/etc "secrets"))))
 
-;; better $PATH (and other environment variable) handling
-(use-package exec-path-from-shell
-  :defer 0.4
-  :init
-  (setq exec-path-from-shell-arguments           nil
-        exec-path-from-shell-check-startup-files nil)
-  :config
-  (exec-path-from-shell-initialize)
-  ;; while we're at it, let's fix access to our running ssh-agent
-  (exec-path-from-shell-copy-env "SSH_AGENT_PID")
-  (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
-
 ;; start up emacs server.  see
 ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server
 (use-package server
@@ -357,18 +353,16 @@ For disabling the behaviour for certain buffers and/or modes."
 
 ;; time and battery in mode-line
 (use-package time
-  :if b/exwm-p
   :demand
   :config
   (display-time-mode)
   :custom
   (display-time-default-load-average nil)
-  (display-time-format "%a %b %-e, %-l:%M%P")
+  (display-time-format "%a %b %-e %-l:%M%P")
   (display-time-mail-icon '(image :type xpm :file "gnus/gnus-pointer.xpm" :ascent center))
   (display-time-use-mail-icon t))
 
 (use-package battery
-  :if b/exwm-p
   :demand
   :config
   (display-battery-mode)
@@ -707,7 +701,7 @@ around if needed."
   (exwm-manage-finish . (lambda ()
                           (when exwm-class-name
                             (cond
-                             ((string= exwm-class-name "Abrowser")
+                             ((string= exwm-class-name "IceCat")
                               (exwm-input-set-local-simulation-keys
                                `(,@exwm-input-simulation-keys
                                  ([?\C-\S-d] . [?\C-d]))))
@@ -882,8 +876,9 @@ around if needed."
 
 (bind-keys
  ("C-c f ." . find-file)
+ ("C-c f d" . find-name-dired)
  ("C-c f l" . find-library)
- ("C-c f r" . recentf-open-files)
;; ("C-c f r" . recentf-open-files)
  ("C-c x"   . execute-extended-command))
 
 (comment
@@ -993,22 +988,6 @@ This function is intended for use with `ivy-ignore-buffers'."
   (counsel-mode 1)
   (defalias 'locate #'counsel-locate))
 
-(comment
-  (use-package helm
-    :commands (helm-M-x helm-mini helm-resume)
-    :bind (("M-x"     . helm-M-x)
-           ("M-y"     . helm-show-kill-ring)
-           ("C-x b"   . helm-mini)
-           ("C-x C-b" . helm-buffers-list)
-           ("C-x C-f" . helm-find-files)
-           ("C-h r"   . helm-info-emacs)
-           ("C-s-r"   . helm-resume)
-           :map helm-map
-           ("<tab>" . helm-execute-persistent-action)
-           ("C-i"   . helm-execute-persistent-action) ; Make TAB work in terminals
-           ("C-z"   . helm-select-action))            ; List actions
-    :config (helm-mode 1)))
-
 (use-package eshell
   :defer 0.5
   :commands eshell
@@ -1043,6 +1022,21 @@ This function is intended for use with `ivy-ignore-buffers'."
       (bind-keys :map eshell-mode-map
                  ("M-r" . counsel-esh-history))))
 
+  (setq
+   eshell-prompt-regexp "\\(.*\n\\)*[$#] "
+   eshell-prompt-function
+   (lambda ()
+     (concat
+      (propertize (format "%s@%s:" (user-login-name) (system-name))
+                  'face 'default)
+      (propertize (abbreviate-file-name default-directory)
+                  'face 'font-lock-comment-face)
+      (propertize "\n" 'face 'default)
+      (if (= (user-uid) 0)
+          (propertize "#" 'face 'red)
+        (propertize "$" 'face 'default))
+      (propertize " " 'face 'default))))
+
   :hook (eshell-mode . b/eshell-setup)
   :custom
   (eshell-hist-ignoredups t)
@@ -1079,7 +1073,8 @@ This function is intended for use with `ivy-ignore-buffers'."
         (mode . message-mode)))
       ("web"
        (or
-        (mode . web-mode)
+        ;; (mode . web-mode)
+        (mode . mhtml-mode)
         (mode . css-mode)
         (mode . scss-mode)
         (mode . js2-mode)))
@@ -1186,8 +1181,8 @@ This function is intended for use with `ivy-ignore-buffers'."
           ("\\.flac\\'" "mpv")))
   :bind (:map dired-mode-map
               ("b"  . dired-up-directory)
-              ("e"  . dired-ediff-files)
-              ("E"  . dired-toggle-read-only)
+              ("E"  . dired-ediff-files)
+              ("e"  . dired-toggle-read-only)
               ("\\" . dired-hide-details-mode)
               ("z"  . (lambda ()
                         (interactive)
@@ -1206,9 +1201,6 @@ This function is intended for use with `ivy-ignore-buffers'."
   (add-to-list 'tramp-default-proxies-alist
                (list (regexp-quote (system-name)) nil nil)))
 
-(use-package dash
-  :config (dash-enable-font-lock))
-
 (use-package doc-view
   :bind (:map doc-view-mode-map
               ("M-RET" . image-previous-line)))
@@ -1277,6 +1269,7 @@ This function is intended for use with `ivy-ignore-buffers'."
   :mode "\\.bashrc$")
 
 (use-package company
+  :disabled
   :bind
   (:map company-active-map
         ([tab]    . company-complete-common-or-cycle)
@@ -1388,132 +1381,24 @@ This function is intended for use with `ivy-ignore-buffers'."
         lean-input-user-translations '(("/" "/")))
   (lean-input-setup))
 
-(comment
-  (use-package proof-site                 ; for Coq
-    :straight proof-general)
-
-  (use-package haskell-mode
-    :config
-    (setq haskell-indentation-layout-offset 4
-          haskell-indentation-left-offset 4
-          flycheck-checker 'haskell-hlint
-          flycheck-disabled-checkers '(haskell-stack-ghc haskell-ghc)))
-
-  (use-package dante
-    :after haskell-mode
-    :commands dante-mode
-    :hook (haskell-mode . dante-mode))
-
-  (use-package hlint-refactor
-    :after haskell-mode
-    :bind (:map hlint-refactor-mode-map
-                ("C-c l b" . hlint-refactor-refactor-buffer)
-                ("C-c l r" . hlint-refactor-refactor-at-point))
-    :hook (haskell-mode . hlint-refactor-mode))
-
-  (use-package flycheck-haskell
-    :after haskell-mode)
-  ;; alternative: hs-lint https://github.com/ndmitchell/hlint/blob/20e116a043f2073c57b17b24ae6364b5e433ba7e/data/hs-lint.el
-  )
+(use-package mhtml-mode)
 
 (use-package sgml-mode
   :config
-  (setq sgml-basic-offset 2))
+  (setq sgml-basic-offset 0))
 
 (use-package css-mode
   :config
   (setq css-indent-offset 2))
 
-(use-package web-mode
-  :mode "\\.html\\'"
-  :config
-  (b/setq-every 2
-    web-mode-code-indent-offset
-    web-mode-css-indent-offset
-    web-mode-markup-indent-offset)
-  :custom
-  (web-mode-enable-auto-indentation nil))
-
 (use-package emmet-mode
-  :after (:any web-mode css-mode sgml-mode)
+  :after (:any mhtml-mode css-mode sgml-mode)
   :bind* (("C-)" . emmet-next-edit-point)
           ("C-(" . emmet-prev-edit-point))
   :config
   (unbind-key "C-j" emmet-mode-keymap)
   (setq emmet-move-cursor-between-quotes t)
-  :hook (web-mode css-mode html-mode sgml-mode))
-
-(comment
-  (use-package meghanada
-    :bind
-    (:map meghanada-mode-map
-          (("C-M-o" . meghanada-optimize-import)
-           ("C-M-t" . meghanada-import-all)))
-    :hook (java-mode . meghanada-mode)))
-
-(comment
-  (use-package treemacs
-    :config (setq treemacs-never-persist t))
-
-  (use-package yasnippet
-    :config
-    ;; (yas-global-mode)
-    )
-
-  (use-package lsp-mode
-    :init (setq lsp-eldoc-render-all nil
-                lsp-highlight-symbol-at-point nil)
-    )
-
-  (use-package hydra)
-
-  (use-package company-lsp
-    :after company
-    :config
-    (setq company-lsp-cache-candidates t
-          company-lsp-async t))
-
-  (use-package lsp-ui
-    :config
-    (setq lsp-ui-sideline-update-mode 'point))
-
-  (use-package lsp-java
-    :config
-    (add-hook 'java-mode-hook
-              (lambda ()
-                (setq-local company-backends (list 'company-lsp))))
-
-    (add-hook 'java-mode-hook 'lsp-java-enable)
-    (add-hook 'java-mode-hook 'flycheck-mode)
-    (add-hook 'java-mode-hook 'company-mode)
-    (add-hook 'java-mode-hook 'lsp-ui-mode))
-
-  (use-package dap-mode
-    :after lsp-mode
-    :config
-    (dap-mode t)
-    (dap-ui-mode t))
-
-  (use-package dap-java
-    :after (lsp-java))
-
-  (use-package lsp-java-treemacs
-    :after (treemacs)))
-
-(comment
-  (use-package eclim
-    :bind (:map eclim-mode-map ("S-SPC" . company-complete))
-    :hook ((java-mode . eclim-mode)
-           (eclim-mode . (lambda ()
-                           (make-local-variable 'company-idle-delay)
-                           (defvar company-idle-delay)
-                           ;; (setq company-idle-delay 0.7)
-                           (setq company-idle-delay nil))))
-    :custom
-    (eclim-auto-save nil)
-    ;; (eclimd-default-workspace "~/src/eclipse-workspace-exp")
-    (eclim-executable "~/.p2/pool/plugins/org.eclim_2.8.0/bin/eclim")
-    (eclim-eclipse-dirs '("~/usr/eclipse/dsl-2018-09/eclipse"))))
+  :hook (css-mode html-mode sgml-mode))
 
 (use-package geiser)
 
@@ -1559,6 +1444,8 @@ This function is intended for use with `ivy-ignore-buffers'."
   :commands (sml/apply-theme)
   :demand
   :config
+  ;; thanks, but no thnaks; don't make fixed-width fills.
+  (defun sml/fill-for-buffer-identification () "")
   (setq sml/theme 'tangomod)
   (sml/setup)
   (smart-mode-line-enable))
@@ -1572,11 +1459,6 @@ This function is intended for use with `ivy-ignore-buffers'."
 
 (use-package doom-themes)
 
-(use-package solarized-theme
-  :disabled
-  :config
-  (load-theme 'solarized-light t))
-
 (use-package moody
   :disabled
   :demand
@@ -1687,12 +1569,6 @@ This function is intended for use with `ivy-ignore-buffers'."
     "C-c f n" "footnote")
   (which-key-add-major-mode-key-based-replacements 'org-mode
     "C-c C-v" "org-babel")
-  (which-key-add-major-mode-key-based-replacements 'web-mode
-    "C-c C-a" "web/attributes"
-    "C-c C-b" "web/blocks"
-    "C-c C-d" "web/dom"
-    "C-c C-e" "web/element"
-    "C-c C-t" "web/tags")
 
   (which-key-mode)
   :custom
@@ -1716,6 +1592,7 @@ This function is intended for use with `ivy-ignore-buffers'."
          ("<end>"  . mwim-end-of-line-or-code)))
 
 (use-package projectile
+  :disabled
   :defer 0.5
   :bind-keymap ("C-c p" . projectile-command-map)
   :config
@@ -1798,46 +1675,12 @@ This function is intended for use with `ivy-ignore-buffers'."
   :after message
   :hook (message-mode . orgalist-mode))
 
-;; easily type pretty quotes & other typography, like ‘’“”-–—«»‹›
-(use-package typo
-  :defer 0.5
-  :config
-  :hook (((text-mode erc-mode web-mode) . typo-mode)
-         ((tex-mode git-commit-mode)    . (lambda ()(typo-mode -1)))))
-
-(use-package electric
-  :disabled
-  :demand
-  :config
-  (electric-quote-mode))
-
 ;; highlight TODOs in buffers
 (use-package hl-todo
   :defer 0.5
   :config
   (global-hl-todo-mode))
 
-(use-package shrink-path
-  :defer 0.5
-  :after eshell
-  :config
-  (defvar user-@-host (concat (user-login-name) "@" (system-name) ":"))
-  (defun +eshell/prompt ()
-    (concat (propertize user-@-host 'face 'default)
-            (propertize (abbreviate-file-name default-directory)
-                        'face 'font-lock-comment-face)
-            (propertize "\n" 'face 'default)
-            (if (= (user-uid) 0)
-                (propertize "#" 'face 'red)
-              (propertize "$" 'face 'default))
-            (propertize " " 'face 'default)))
-  (setq eshell-prompt-regexp "\\(.*\n\\)*[$#] "
-        eshell-prompt-function #'+eshell/prompt))
-
-(use-package eshell-up
-  :after eshell
-  :commands eshell-up)
-
 (use-package multi-term
   :disabled
   :defer 0.6
@@ -1911,11 +1754,6 @@ This function is intended for use with `ivy-ignore-buffers'."
                ("p" . mc/mark-previous-like-this)
                ("a" . mc/mark-all-like-this))))
 
-(use-package forge
-  :disabled
-  :demand
-  :after magit)
-
 (use-package yasnippet
   :defer 0.6
   :config
@@ -1942,19 +1780,24 @@ This function is intended for use with `ivy-ignore-buffers'."
    ("C-c D b" . debbugs-gnu-bugs)
    ("C-c D e" .
     (lambda ()
-      (interactive)
+      (interactive)                     ; bug-gnu-emacs
       (setq debbugs-gnu-current-suppress t)
       (debbugs-gnu debbugs-gnu-default-severities '("emacs"))))
-   ("C-c D g" .
+   ("C-c D g" .                         ; bug-gnuzilla
     (lambda ()
       (interactive)
       (setq debbugs-gnu-current-suppress t)
       (debbugs-gnu debbugs-gnu-default-severities '("gnuzilla"))))
-   ("C-c D G" .
+   ("C-c D G b" .                       ; bug-guix
     (lambda ()
       (interactive)
       (setq debbugs-gnu-current-suppress t)
-      (debbugs-gnu debbugs-gnu-default-severities '("guix"))))))
+      (debbugs-gnu debbugs-gnu-default-severities '("guix"))))
+   ("C-c D G p" .                       ; guix-patches
+    (lambda ()
+      (interactive)
+      (setq debbugs-gnu-current-suppress t)
+      (debbugs-gnu debbugs-gnu-default-severities '("guix-patches"))))))
 
 (use-package org-ref
   :init
@@ -1965,16 +1808,8 @@ This function is intended for use with `ivy-ignore-buffers'."
    org-ref-bibliography-notes "~/usr/org/notes.org"
    org-ref-pdf-directory "~/usr/org/bibtex-pdfs/"))
 
-(use-package alert
-  :commands (alert)
-  :init (setq alert-default-style 'notifications))
-
 ;; (use-package fill-column-indicator)
 
-(use-package emojify
-  :disabled
-  :hook (erc-mode . emojify-mode))
-
 (use-package window
   :bind
   (("C-c w e"   . (lambda ()
@@ -2073,42 +1908,18 @@ This function is intended for use with `ivy-ignore-buffers'."
   :config
   (eosd-start))
 
-(use-package nnreddit
-  :disabled
-  :demand
-  :after gnus
-  :custom
-  (nnreddit-python-command "python3"))
-
-(use-package hyperbole
-  :disabled
-  :straight (hyperbole
-             :host github :repo "rswgnu/hyperbole"
-             :files ("*.el" ("kotl" "kotl/*.el")
-                     "DEMO" "man/*.info" "man/*.texi")))
-
-;; (use-package oddmuse-curl
-;;   :straight (:host github :repo "kensanata/oddmuse-curl")
-;;   :config
-;;   (setq
-;;    oddmuse-wikis
-;;    (append
-;;     '(("EmacsConf" "https://emacsconf.org" utf-8 "question" nil)
-;;       ("EmacsConf 2019" "https://emacsconf.org/2019" utf-8 "question" nil))
-;;     oddmuse-wikis))
-;;   :custom
-;;   (oddmuse-username "bandali"))
-
-(use-package debpaste
-  :custom
-  (debpaste-paste-is-hidden t))
-
 (use-package scpaste
   :disabled
   :config
   (setq scpaste-http-destination "https://p.bndl.org"
         scpaste-scp-destination "nix:/var/www/p.bndl.org"))
 
+(use-package eww
+  :bind ("C-c a e w" . eww)
+  :custom
+  (eww-download-directory (file-name-as-directory
+                           (getenv "XDG_DOWNLOAD_DIR"))))
+
 \f
 ;;; Email (with Gnus)
 
@@ -2122,9 +1933,9 @@ This function is intended for use with `ivy-ignore-buffers'."
  read-mail-command 'gnus)
 
 (use-package gnus
-  :bind (("s-m"     . gnus)
+  :bind (("s-m"     . gnus-plugged)
          ("s-M"     . gnus-unplugged)
-         ("C-c a m" . gnus)
+         ("C-c a m" . gnus-plugged)
          ("C-c a M" . gnus-unplugged))
   :init
   (setq
@@ -2141,7 +1952,7 @@ This function is intended for use with `ivy-ignore-buffers'."
              (nnimap-address "127.0.0.1")
              (nnimap-server-port 143)
              (nnimap-authenticator plain)
-             (nnimap-user "mab@gnu.local")
+             (nnimap-user "bandali@gnu.local")
              (nnimap-inbox "INBOX")
              (nnimap-split-methods 'nnimap-split-fancy)
              (nnimap-split-fancy (|
@@ -2432,7 +2243,7 @@ https://csclub.uwaterloo.ca/~abandali")
   (setq gnus-message-replysign t
         gnus-posting-styles
         '((".*"
-           (address "mab@gnu.org"))
+           (address "bandali@gnu.org"))
           ("nnimap\\+gnu:l\\..*"
            (signature nil))
           ("nnimap\\+gnu:.*"
@@ -2544,7 +2355,7 @@ https://csclub.uwaterloo.ca/~abandali")
         message-subscribed-address-functions
         '(gnus-find-subscribed-addresses)
         message-dont-reply-to-names
-        "\\(\\(\\(amin\\|mab\\)@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(mab\\|bandali\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
+        "\\(\\(amin@shemshak\\.org\\)\\|\\(.*@aminb\\.org\\)\\|\\(\\(bandali\\|mab\\|aminb?\\)@gnu\\.org\\)\\|\\(a?bandali@\\(csclub\\.\\)?uwaterloo\\.ca\\)\\)")
   ;; (require 'company-ebdb)
   :hook (;; (message-setup . mml-secure-message-sign-pgpmime)
          (message-mode . flyspell-mode)
@@ -2585,17 +2396,6 @@ https://csclub.uwaterloo.ca/~abandali")
         ("r" . footnote-renumber-footnotes)
         ("s" . footnote-set-style)))
 
-(use-package bbdb
-  :disabled
-  :demand
-  :after gnus
-  :bind (:map gnus-group-mode-map ("e" . bbdb))
-  :config
-  (bbdb-initialize 'gnus 'message)
-  :custom
-  (bbdb-complete-mail-allow-cycling t)
-  (bbdb-user-mail-address-re message-dont-reply-to-names))
-
 (use-package ebdb
   :demand
   :after gnus
@@ -2744,8 +2544,6 @@ https://csclub.uwaterloo.ca/~abandali")
     (setq znc-servers
           `(("znc.shemshak.org" 1337 t
              ((freenode "amin/freenode" ,pwd)))
-            ("znc.shemshak.org" 1337 t
-             ((moznet "amin/moznet" ,pwd)))
             ("znc.shemshak.org" 1337 t
              ((oftc "amin/oftc" ,pwd)))))))