From 927b50b7aec2da105bd5125dec272a89e38663c3 Mon Sep 17 00:00:00 2001 From: Amin Bandali Date: Mon, 5 Oct 2020 23:18:01 -0400 Subject: Fold lisp/bandali-utils.el back into init.el --- early-init.el | 9 --- init.el | 182 +++++++++++++++++++++++++++++++++++++----------- lisp/bandali-dired.el | 9 +++ lisp/bandali-erc.el | 22 ++++-- lisp/bandali-gnus.el | 12 ++-- lisp/bandali-message.el | 32 ++++----- lisp/bandali-utils.el | 130 ---------------------------------- 7 files changed, 187 insertions(+), 209 deletions(-) delete mode 100644 lisp/bandali-utils.el diff --git a/early-init.el b/early-init.el index bb6d45c..99646b0 100644 --- a/early-init.el +++ b/early-init.el @@ -2,12 +2,3 @@ ;; https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=24acb31c04b4048b85311d794e600ecd7ce60d3b (setq package-enable-at-startup nil) (setq load-prefer-newer t) -(defmacro comment (&rest _) - "Comment out one or more s-expressions." - (declare (indent defun)) - nil) -(add-to-list - 'load-path - (expand-file-name - (convert-standard-filename "lisp") user-emacs-directory)) -(require 'bandali-utils) diff --git a/init.el b/init.el index 75ec3a3..958f457 100644 --- a/init.el +++ b/init.el @@ -78,7 +78,7 @@ exwm-workspace-current-index)))))))) ;; make some mode-line spaces smaller - (csetq + (setq-default mode-line-format (mapcar (lambda (x) @@ -104,6 +104,26 @@ (setq user-full-name "Amin Bandali" user-mail-address "bandali@gnu.org") + +;;; csetq (`custom' setq) + +(require 'cl-lib) + +(defmacro csetq (&rest args) + "Set the value of user option VAR to VALUE. + +More generally, you can use multiple variables and values, as in + (csetq VAR VALUE VAR VALUE...) +This sets each user option VAR's value to the corresponding VALUE. + +\(fn [VAR VALUE]...)" + (declare (debug setq)) + `(progn + ,@(cl-loop for (var value) on args by 'cddr + collect + `(funcall (or (get ',var 'custom-set) #'set-default) + ',var ,value)))) + ;;; Package management @@ -131,13 +151,13 @@ (debbugs "0.26") (delight "1.7") (ebdb "0.6.19") - (orgalist "1.12") + (orgalist "1.13") (rt-liberation "1.31") (yasnippet "0.14.0") ;; bndl (refinery-theme "0.1.1") ;; Org ELPA - (org-plus-contrib "20200921")))) + (org-plus-contrib "20201005")))) (package-initialize)) (csetq package-archive-upload-base "/ssh:caffeine:~/www/p/elpa") @@ -180,15 +200,14 @@ ;; while at it, treat themes as safe ;; (setf custom-safe-themes t) ;; only one custom theme at a time - (comment - (defadvice load-theme (before clear-previous-themes activate) - "Clear existing theme settings instead of layering them" - (mapc #'disable-theme custom-enabled-themes)))) + ;; (defadvice load-theme (before clear-previous-themes activate) + ;; "Clear existing theme settings instead of layering them" + ;; (mapc #'disable-theme custom-enabled-themes)) + ) ;; load the secrets file if it exists, otherwise show a warning -(comment - (with-demoted-errors - (load (b/etc "secrets")))) +;; (with-demoted-errors +;; (load (b/etc "secrets"))) ;; start up emacs server. see ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html#Emacs-Server @@ -238,37 +257,36 @@ (set-fontset-font t 'arabic "Vazir") ;; unicode support -(comment - (dolist (ft (fontset-list)) - (set-fontset-font - ft - 'unicode - (font-spec :name "Source Code Pro" :size 14)) - (set-fontset-font - ft - 'unicode - (font-spec :name "DejaVu Sans Mono") - nil - 'append) - ;; (set-fontset-font - ;; ft - ;; 'unicode - ;; (font-spec - ;; :name "Symbola monospacified for DejaVu Sans Mono") - ;; nil - ;; 'append) - ;; (set-fontset-font - ;; ft - ;; #x2115 ; ℕ - ;; (font-spec :name "DejaVu Sans Mono") - ;; nil - ;; 'append) - (set-fontset-font - ft - (cons ?Α ?ω) - (font-spec :name "DejaVu Sans Mono" :size 14) - nil - 'prepend))) +;; (dolist (ft (fontset-list)) +;; (set-fontset-font +;; ft +;; 'unicode +;; (font-spec :name "Source Code Pro" :size 14)) +;; (set-fontset-font +;; ft +;; 'unicode +;; (font-spec :name "DejaVu Sans Mono") +;; nil +;; 'append) +;; ;; (set-fontset-font +;; ;; ft +;; ;; 'unicode +;; ;; (font-spec +;; ;; :name "Symbola monospacified for DejaVu Sans Mono") +;; ;; nil +;; ;; 'append) +;; ;; (set-fontset-font +;; ;; ft +;; ;; #x2115 ; ℕ +;; ;; (font-spec :name "DejaVu Sans Mono") +;; ;; nil +;; ;; 'append) +;; (set-fontset-font +;; ft +;; (cons ?Α ?ω) +;; (font-spec :name "DejaVu Sans Mono" :size 14) +;; nil +;; 'prepend)) ;;;; Elisp-level customizations @@ -419,6 +437,82 @@ auth-sources '("~/.authinfo.gpg") authinfo-hidden (regexp-opt '("password" "client-secret" "token"))) + +;;; Useful utilities + +(defun b/add-elisp-section () + (interactive) + (insert "\n") + (forward-line -1) + (insert "\n \n;;; ")) + +(defun b/insert-asterism () + "Insert a centred asterism." + (interactive) + (let ((asterism "* * *")) + (insert + (concat + "\n" + (make-string + (floor (/ (- fill-column (length asterism)) 2)) + ?\s) + asterism + "\n")))) + +(defun b/start-process (program &rest args) + "Same as `start-process', but doesn't bother about name and buffer." + (let ((process-name (concat program "_process")) + (buffer-name (generate-new-buffer-name + (concat program "_output")))) + (apply #'start-process + process-name buffer-name program args))) + +(defun b/no-mouse-autoselect-window () + "Conveniently disable `focus-follows-mouse'. +For disabling the behaviour for certain buffers and/or modes." + (make-local-variable 'mouse-autoselect-window) + (setq mouse-autoselect-window nil)) + +(defun b/kill-current-buffer () + "Kill the current buffer." + ;; also see https://redd.it/64xb3q + (interactive) + (kill-buffer (current-buffer))) + +(defun b/move-indentation-or-beginning-of-line (arg) + "Move to the indentation or to the beginning of line." + (interactive "^p") + ;; (if (bolp) + ;; (back-to-indentation) + ;; (move-beginning-of-line arg)) + (if (= (point) + (progn (back-to-indentation) + (point))) + (move-beginning-of-line arg))) + +(defun b/join-line-top () + "Like `join-line', but join next line to the current line." + (interactive) + (join-line 1)) + +(defun b/duplicate-line-or-region (&optional n) + "Duplicate the current line, or region (if active). +Make N (default: 1) copies of the current line or region." + (interactive "*p") + (let ((u-r-p (use-region-p)) ; if region is active + (n1 (or n 1))) + (save-excursion + (let ((text + (if u-r-p + (buffer-substring (region-beginning) (region-end)) + (prog1 (thing-at-point 'line) + (end-of-line) + (if (eobp) + (newline) + (forward-line 1)))))) + (dotimes (_ (abs n1)) + (insert text)))))) + ;;; General key bindings @@ -465,6 +559,11 @@ ;;; Essential packages +(add-to-list + 'load-path + (expand-file-name + (convert-standard-filename "lisp") user-emacs-directory)) + ;; (require 'bandali-exwm) (require 'bandali-org) @@ -562,6 +661,7 @@ ;; IRC (with ERC) (require 'bandali-erc) +;; 'paste' service (aka scp + web server) (add-to-list 'load-path (b/lisp "scpaste")) (with-eval-after-load 'scpaste (csetq scpaste-http-destination "https://p.bndl.org" diff --git a/lisp/bandali-dired.el b/lisp/bandali-dired.el index 4755a64..9ed1030 100644 --- a/lisp/bandali-dired.el +++ b/lisp/bandali-dired.el @@ -57,6 +57,15 @@ (set-window-configuration wnd)))) (error "no more than 2 files should be marked")))) + (defun b/dired-start-process (program &optional args) + "Open current file with a PROGRAM." + ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS + ;; can be nil, so remove it). + (declare-function dired-get-file-for-visit "dired") + (apply #'b/start-process + program + (remove nil (list args (dired-get-file-for-visit))))) + ;; local key bindings (define-key dired-mode-map (kbd "b") #'dired-up-directory) (define-key dired-mode-map (kbd "E") #'dired-ediff-files) diff --git a/lisp/bandali-erc.el b/lisp/bandali-erc.el index 6beac87..41a152c 100644 --- a/lisp/bandali-erc.el +++ b/lisp/bandali-erc.el @@ -67,9 +67,20 @@ (set-face-attribute 'erc-nick-default-face nil - :weight 'semibold - :background "#f2f2f2" - :foreground "#222222") + ;; :weight 'semibold + ;; :background "#f2f2f2" + ;; :foreground "#222222" + :weight 'bold + :background "#f8f8f8" + :foreground "#6a6a6a") + + ;; (set-face-attribute + ;; 'erc-notice-face nil + ;; ;; :background "#fffadf" + ;; ;; :background "#f9f9f9" + ;; :background 'unspecified + ;; ;; :foreground "#809de5" + ;; :foreground "steel blue") ;; erc-fill ;; (csetq @@ -82,8 +93,9 @@ ;; erc-match (csetq erc-pal-highlight-type 'nick - erc-pals '("aindilis" "blackbeard" "brettgilio" "civodul" "dto" - "ggoes" "jrasata" "mplsCorwin" "rwp" "technomancy")) + erc-pals + '("aindilis" "blackbeard" "bremner" "brettgilio" "civodul" + "dto" "ggoes" "jrasata" "mplsCorwin" "rwp" "technomancy")) (with-eval-after-load 'erc-match (set-face-attribute 'erc-pal-face nil diff --git a/lisp/bandali-gnus.el b/lisp/bandali-gnus.el index 39c9af8..1958793 100644 --- a/lisp/bandali-gnus.el +++ b/lisp/bandali-gnus.el @@ -443,17 +443,15 @@ GNU Jami: bandali") (with-eval-after-load 'gnus-group (csetq gnus-permanently-visible-groups "\\(:INBOX$\\|:gnu$\\)")) -(comment - ;; problematic with ebdb's popup, *EBDB-Gnus* - (with-eval-after-load 'gnus-win - (csetq gnus-use-full-window nil))) +;; problematic with ebdb's popup, *EBDB-Gnus* +;; (with-eval-after-load 'gnus-win +;; (csetq gnus-use-full-window nil)) (with-eval-after-load 'gnus-dired (add-hook 'dired-mode-hook 'gnus-dired-mode)) -(comment - (with-eval-after-load 'gnus-utils - (csetq gnus-completing-read-function 'gnus-ido-completing-read))) +;; (with-eval-after-load 'gnus-utils +;; (csetq gnus-completing-read-function 'gnus-ido-completing-read)) (with-eval-after-load 'mm-decode (csetq mm-discouraged-alternatives '("text/html" "text/richtext") diff --git a/lisp/bandali-message.el b/lisp/bandali-message.el index e7e43f8..c13bffc 100644 --- a/lisp/bandali-message.el +++ b/lisp/bandali-message.el @@ -118,23 +118,21 @@ (make-local-variable 'company-idle-delay) (setq company-idle-delay 0.2))) -(comment - (with-eval-after-load 'message-x - (csetq - message-x-completion-alist - '(("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" - . gnus-harvest-find-address) - ((if - (boundp - (quote message-newgroups-header-regexp)) - message-newgroups-header-regexp message-newsgroups-header-regexp) - . message-expand-group))))) - -(comment - (require 'gnus-harvest) - (if (featurep 'message-x) - (gnus-harvest-install 'message-x) - (gnus-harvest-install))) +;; (with-eval-after-load 'message-x +;; (csetq +;; message-x-completion-alist +;; '(("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" +;; . gnus-harvest-find-address) +;; ((if +;; (boundp +;; (quote message-newgroups-header-regexp)) +;; message-newgroups-header-regexp message-newsgroups-header-regexp) +;; . message-expand-group)))) + +;; (require 'gnus-harvest) +;; (if (featurep 'message-x) +;; (gnus-harvest-install 'message-x) +;; (gnus-harvest-install)) (provide 'bandali-message) ;;; bandali-message.el ends here diff --git a/lisp/bandali-utils.el b/lisp/bandali-utils.el deleted file mode 100644 index 6669b2a..0000000 --- a/lisp/bandali-utils.el +++ /dev/null @@ -1,130 +0,0 @@ -;;; bandali-utils.el --- useful utilities -*- lexical-binding: t; -*- - -;; Copyright (C) 2020 Amin Bandali - -;; Author: Amin Bandali -;; Keywords: lisp, tools - -;; 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 -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; A small collection of useful utilities used through my init files. - -;;; Code: - -(require 'cl-lib) - -(defmacro csetq (&rest args) - "Set the value of user option VAR to VALUE. - -More generally, you can use multiple variables and values, as in - (csetq VAR VALUE VAR VALUE...) -This sets each user option VAR's value to the corresponding VALUE. - -\(fn [VAR VALUE]...)" - (declare (debug setq)) - `(progn - ,@(cl-loop for (var value) on args by 'cddr - collect - `(funcall (or (get ',var 'custom-set) #'set-default) - ',var ,value)))) - -(defun b/start-process (program &rest args) - "Same as `start-process', but doesn't bother about name and buffer." - (let ((process-name (concat program "_process")) - (buffer-name (generate-new-buffer-name - (concat program "_output")))) - (apply #'start-process - process-name buffer-name program args))) - -(defun b/dired-start-process (program &optional args) - "Open current file with a PROGRAM." - ;; Shell command looks like this: "program [ARGS]... FILE" (ARGS can - ;; be nil, so remove it). - (declare-function dired-get-file-for-visit "dired") - (apply #'b/start-process - program - (remove nil (list args (dired-get-file-for-visit))))) - -(defun b/add-elisp-section () - (interactive) - (insert "\n") - (forward-line -1) - (insert "\n \n;;; ")) - -;; (defvar b/fill-column 47 -;; "My custom `fill-column'.") - -(defconst b/asterism "* * *") - -(defun b/insert-asterism () - "Insert a centred asterism." - (interactive) - (insert - (concat - "\n" - (make-string (floor (/ (- fill-column (length b/asterism)) 2)) - ?\s) - b/asterism - "\n"))) - -(defun b/no-mouse-autoselect-window () - "Conveniently disable `focus-follows-mouse'. -For disabling the behaviour for certain buffers and/or modes." - (make-local-variable 'mouse-autoselect-window) - (setq mouse-autoselect-window nil)) - -(defun b/kill-current-buffer () - "Kill the current buffer." - ;; also see https://redd.it/64xb3q - (interactive) - (kill-buffer (current-buffer))) - -(defun b/move-indentation-or-beginning-of-line (arg) - "Move to the indentation or to the beginning of line." - (interactive "^p") - ;; (if (bolp) - ;; (back-to-indentation) - ;; (move-beginning-of-line arg)) - (if (= (point) - (progn (back-to-indentation) - (point))) - (move-beginning-of-line arg))) - -(defun b/join-line-top () - "Like `join-line', but join next line to the current line." - (interactive) - (join-line 1)) - -(defun b/duplicate-line-or-region (&optional n) - "Duplicate the current line, or region (if active). -Make N (default: 1) copies of the current line or region." - (interactive "*p") - (let ((u-r-p (use-region-p)) ; if region is active - (n1 (or n 1))) - (save-excursion - (let ((text - (if u-r-p - (buffer-substring (region-beginning) (region-end)) - (prog1 (thing-at-point 'line) - (end-of-line) - (if (eobp) - (newline) - (forward-line 1)))))) - (dotimes (_ (abs n1)) - (insert text)))))) - -(provide 'bandali-utils) -;;; bandali-utils.el ends here -- cgit v1.2.3-60-g2f50