aboutsummaryrefslogtreecommitdiff
path: root/bard-elisp
diff options
context:
space:
mode:
Diffstat (limited to 'bard-elisp')
-rw-r--r--bard-elisp/bard-calendar.el35
-rw-r--r--bard-elisp/bard-compile.el1
-rw-r--r--bard-elisp/bard-eshell.el40
-rw-r--r--bard-elisp/bard-media.el53
-rw-r--r--bard-elisp/bard-modeline.el26
-rw-r--r--bard-elisp/bard-package.el2
-rw-r--r--bard-elisp/bard-theme.el117
-rw-r--r--bard-elisp/bard-window.el2
-rw-r--r--bard-elisp/bard-writing.el111
9 files changed, 149 insertions, 238 deletions
diff --git a/bard-elisp/bard-calendar.el b/bard-elisp/bard-calendar.el
index 7c2efc6..0fd9e3a 100644
--- a/bard-elisp/bard-calendar.el
+++ b/bard-elisp/bard-calendar.el
@@ -1,7 +1,5 @@
(require 'org)
-;; Org Clock
-
(defun bard/auto-clock-in ()
"Automatically clock in when task marked in progress (INPROG),
and start study session."
@@ -25,22 +23,25 @@
(pop-to-buffer-same-window "todo.org")))))))
(defun bard/org-clock-report ()
- (interactive)
- (bard/new-org-buffer)
- (org-clock-report))
+ "Generate an org clock report in a separate org buffer."
+ (interactive)
+ (bard/new-org-buffer)
+ (org-clock-report))
-(defun bard/org-clock-update-mode-line ()
- (interactive)
- (setq org-mode-line-string nil)
- (force-mode-line-update))
+ (defun bard/org-clock-update-mode-line ()
+ "Update the modeline, not sure why I have this."
+ (interactive)
+ (setq org-mode-line-string nil)
+ (force-mode-line-update))
-(defun bard/org-clock-task-string ()
- "Return a simplified org clock task string."
- (if (and (boundp 'org-mode-line-string)
- (not (string-equal "" org-mode-line-string))
- org-mode-line-string)
- (substring-no-properties org-mode-line-string)
- "No task clocked in"))
+ (defun bard/org-clock-task-string ()
+ "Return a simplified org clock task string.
+Used in FVWM3 configuration to show clocked task in FVWMbuttons."
+ (if (and (boundp 'org-mode-line-string)
+ (not (string-equal "" org-mode-line-string))
+ org-mode-line-string)
+ (substring-no-properties org-mode-line-string)
+ "No task clocked in"))
(defun bard/open-calendar ()
"Opens calendar as only window"
@@ -48,8 +49,6 @@
(calendar)
(delete-other-windows))
-;; Org Agenda
-
(defun bard/choose-agenda ()
"For viewing my custom agenda"
(interactive)
diff --git a/bard-elisp/bard-compile.el b/bard-elisp/bard-compile.el
index 5c4d20f..7892288 100644
--- a/bard-elisp/bard-compile.el
+++ b/bard-elisp/bard-compile.el
@@ -1,4 +1,3 @@
-;; Stolen from (http://endlessparentheses.com/ansi-colors-in-the-compilation-buffer-output.html)
(require 'ansi-color)
(defun endless/colorize-compilation ()
"Colorize from `compilation-filter-start' to `point'."
diff --git a/bard-elisp/bard-eshell.el b/bard-elisp/bard-eshell.el
index e50a707..1b118a7 100644
--- a/bard-elisp/bard-eshell.el
+++ b/bard-elisp/bard-eshell.el
@@ -4,15 +4,15 @@
;; aliases
(setq bard/eshell-aliases
'((g . magit)
- (gl . magit-log)
- (d . dired)
- (o . find-file)
- (oo . find-file-other-window)
- (l . (lambda () (eshell/ls '-la)))
- (eshell/clear . eshell/clear-scrollback)))
+ (gl . magit-log)
+ (d . dired)
+ (o . find-file)
+ (oo . find-file-other-window)
+ (l . (lambda () (eshell/ls '-la)))
+ (eshell/clear . eshell/clear-scrollback)))
(mapc (lambda (alias)
- (defalias (car alias) (cdr alias)))
+ (defalias (car alias) (cdr alias)))
bard/eshell-aliases)
(defun prot-eshell--cd (dir)
@@ -47,7 +47,7 @@ open the directory in a `dired' buffer."
(interactive)
(let ((file (ffap-file-at-point)))
(if file
- (find-file file)
+ (find-file file)
(user-error "No file at point"))))
(defcustom prot-eshell-output-buffer "*Exported Eshell output*"
@@ -119,24 +119,24 @@ append to it, while separating multiple outputs with
(if (string= arg "New eshell")
(eshell t)
(switch-to-buffer arg)))
- (defun eshell-switcher (&optional arg)
- "Commentary ARG."
- (interactive)
- (let* (
- (buffers (cl-remove-if-not (lambda (n) (eq (buffer-local-value 'major-mode n) 'eshell-mode)) (buffer-list)) )
- (names (mapcar (lambda (n) (buffer-name n)) buffers))
- (num-buffers (length buffers) )
- (in-eshellp (eq major-mode 'eshell-mode)))
- (cond ((eq num-buffers 0) (eshell (or arg t)))
- ((not in-eshellp) (switch-to-buffer (car buffers)))
- (t (select-or-create (completing-read "Select Shell:" (cons "New eshell" names)))))))
+(defun eshell-switcher (&optional arg)
+ "Commentary ARG."
+ (interactive)
+ (let* (
+ (buffers (cl-remove-if-not (lambda (n) (eq (buffer-local-value 'major-mode n) 'eshell-mode)) (buffer-list)) )
+ (names (mapcar (lambda (n) (buffer-name n)) buffers))
+ (num-buffers (length buffers) )
+ (in-eshellp (eq major-mode 'eshell-mode)))
+ (cond ((eq num-buffers 0) (eshell (or arg t)))
+ ((not in-eshellp) (switch-to-buffer (car buffers)))
+ (t (select-or-create (completing-read "Select Shell:" (cons "New eshell" names)))))))
;; taken from https://github.com/karthink/.emacs.d/blob/master/lisp/setup-shells.el
(use-package eshell
:defer
:config
(setq eshell-prompt-regexp "^.* λ "
- eshell-prompt-function #'bard/eshell-default-prompt-fn)
+ eshell-prompt-function #'bard/eshell-default-prompt-fn)
(defun bard/eshell-default-prompt-fn ()
"Generate the prompt string for eshell. Use for `eshell-prompt-function'."
diff --git a/bard-elisp/bard-media.el b/bard-elisp/bard-media.el
index b5d1707..b7ebacd 100644
--- a/bard-elisp/bard-media.el
+++ b/bard-elisp/bard-media.el
@@ -23,6 +23,32 @@
(emms-playlist-save bard/emms-playlist-format bard/watch-later-file)
(message "Playlist saved to %s" bard/watch-later-file)))
+(defun bard/emms-download-current-video (destination)
+ "Download the currently playing EMMS video and move it to DESTINATION."
+ (interactive "DSelect destination directory: ")
+ (require 'emms)
+ (let* ((track (emms-playlist-current-selected-track))
+ (url (emms-track-get track 'name))
+ (default-directory (file-name-as-directory temporary-file-directory))
+ (downloader (executable-find "yt-dlp"))
+ (output-template "%(title)s.%(ext)s"))
+ (unless downloader
+ (error "yt-dlp or youtube-dl is not installed or not in PATH"))
+ (unless (string-match-p "^https?://" url)
+ (error "Current track is not a valid video URL"))
+
+ (let ((cmd (format "%s -o \"%s\" \"%s\""
+ downloader output-template url)))
+ (message "Downloading video from: %s" url)
+ (let ((exit-code (shell-command cmd)))
+ (if (not (eq exit-code 0))
+ (error "Download failed, see *Messages* for details")
+ ;; Move the downloaded file
+ (let* ((downloaded-file (car (directory-files default-directory t ".*\\(mp4\\|mkv\\|webm\\)$" 'time)))
+ (target-path (expand-file-name (file-name-nondirectory downloaded-file) destination)))
+ (rename-file downloaded-file target-path t)
+ (message "Video saved to: %s" target-path)))))))
+
(defun bard/image-browser-choose (directory)
"Open nsxiv in thumbnail mode on DIRECTORY.
Asks the user whether to enable recursive mode and whether to output marked files to a buffer."
@@ -31,7 +57,6 @@ Asks the user whether to enable recursive mode and whether to output marked file
(stdout (if (y-or-n-p "Output marked files to buffer? ") "-o" ""))
(full-dir (expand-file-name directory))
(args (remove "" (list "nsxiv" "-t" stdout recursive full-dir))))
-
;; Pre-clear the output buffer if needed
(when (string= stdout "-o")
(with-current-buffer (get-buffer-create "*nsxiv*")
@@ -91,30 +116,4 @@ Assumes that files have already been validated."
(message "Not in Dired. Prompting for directory...")
(call-interactively #'bard/image-browser-choose))))
-(defun bard/emms-download-current-video (destination)
- "Download the currently playing EMMS video and move it to DESTINATION."
- (interactive "DSelect destination directory: ")
- (require 'emms)
- (let* ((track (emms-playlist-current-selected-track))
- (url (emms-track-get track 'name))
- (default-directory (file-name-as-directory temporary-file-directory))
- (downloader (executable-find "yt-dlp"))
- (output-template "%(title)s.%(ext)s"))
- (unless downloader
- (error "yt-dlp or youtube-dl is not installed or not in PATH"))
- (unless (string-match-p "^https?://" url)
- (error "Current track is not a valid video URL"))
-
- (let ((cmd (format "%s -o \"%s\" \"%s\""
- downloader output-template url)))
- (message "Downloading video from: %s" url)
- (let ((exit-code (shell-command cmd)))
- (if (not (eq exit-code 0))
- (error "Download failed, see *Messages* for details")
- ;; Move the downloaded file
- (let* ((downloaded-file (car (directory-files default-directory t ".*\\(mp4\\|mkv\\|webm\\)$" 'time)))
- (target-path (expand-file-name (file-name-nondirectory downloaded-file) destination)))
- (rename-file downloaded-file target-path t)
- (message "Video saved to: %s" target-path)))))))
-
(provide 'bard-media.el)
diff --git a/bard-elisp/bard-modeline.el b/bard-elisp/bard-modeline.el
index dd6a3d0..39b710f 100644
--- a/bard-elisp/bard-modeline.el
+++ b/bard-elisp/bard-modeline.el
@@ -20,9 +20,9 @@ on whether the mode line belongs to the currently selected window
or not."
(let ((window (selected-window)))
(or (eq window (old-selected-window))
- (and (minibuffer-window-active-p (minibuffer-window))
- (with-selected-window (minibuffer-window)
- (eq window (minibuffer-selected-window)))))))
+ (and (minibuffer-window-active-p (minibuffer-window))
+ (with-selected-window (minibuffer-window)
+ (eq window (minibuffer-selected-window)))))))
;;;; Faces
@@ -382,26 +382,6 @@ face. Let other buffers have no face.")
(substring rev 0 7))))
(capitalize branch)))
-;; NOTE 2023-07-27: This is a good idea, but it hardcodes Git, whereas
-;; I want a generic VC method. Granted, I only use Git but I still
-;; want it to work as a VC extension.
-
-;; (defun prot-modeline-diffstat (file)
-;; "Return shortened Git diff numstat for FILE."
-;; (when-let* ((output (shell-command-to-string (format "git diff --numstat %s" file)))
-;; (stats (split-string output "[\s\t]" :omit-nulls "[\s\f\t\n\r\v]+"))
-;; (added (nth 0 stats))
-;; (deleted (nth 1 stats)))
-;; (cond
-;; ((and (equal added "0") (equal deleted "0"))
-;; "")
-;; ((and (not (equal added "0")) (equal deleted "0"))
-;; (propertize (format "+%s" added) 'face 'shadow))
-;; ((and (equal added "0") (not (equal deleted "0")))
-;; (propertize (format "-%s" deleted) 'face 'shadow))
-;; (t
-;; (propertize (format "+%s -%s" added deleted) 'face 'shadow)))))
-
(declare-function vc-git-working-revision "vc-git" (file))
(defvar prot-modeline-vc-map
diff --git a/bard-elisp/bard-package.el b/bard-elisp/bard-package.el
index 9f2aee2..77ac887 100644
--- a/bard-elisp/bard-package.el
+++ b/bard-elisp/bard-package.el
@@ -1,4 +1,4 @@
-;; taken and renamed functions from https://manueluberti.eu/posts/2021-09-01-package-report/
+;; taken and renamed functions from
(defun bard/package-report ()
"Report total package counts grouped by archive."
diff --git a/bard-elisp/bard-theme.el b/bard-elisp/bard-theme.el
index 9150bfd..26e57fa 100644
--- a/bard-elisp/bard-theme.el
+++ b/bard-elisp/bard-theme.el
@@ -1,60 +1,56 @@
(setq fontaine-presets
- '((default
- :default-height 140
- :default-family "Iosevka Comfy"
- :variable-pitch-family "Iosevka Comfy"
- :variable-pitch-height 1.0
- :fixed-pitch-family "Iosevka Comfy"
- :fixed-pitch-height 1.0
- :bold-weight bold
- )
- (tiny
- :inherit default
- :default-height 135)
- (wide
- :default-height 135
- :default-family "Iosevka Comfy Wide"
- :fixed-pitch-family "Iosevka Comfy Wide"
- :variable-pitch-family "Iosevka Comfy Wide Motion Duo")
- (prot
- :default-family "Iosevka Comfy Wide Motion"
- :default-height 130
- :default-weight medium
- :fixed-pitch-family "Iosevka Comfy Wide Motion"
- :variable-pitch-family "Iosevka Comfy Wide Duo"
- :bold-weight extrabold)
- (mono
- :default-height 130
- :default-family "monospace"
- :fixed-pitch-family "monospace"
- :variable-pitch-family "Baskerville"
- :variable-pitch-height 140)
- (mono-large
- :inherit mono
- :default-height 150
- :variable-pitch-height 160)
- (mac
- :default-height 130
- :default-family "Monaco"
- :variable-pitch-family "Monaco"
- :fixed-pitch-family "Monaco")
- (large
- :inherit default
- :default-height 160
- )
- (huge
- :inherit default
- :default-height 180
- )
- (t
- :default-family "Monospace"
- )))
+ '((default
+ :default-height 140
+ :default-family "Iosevka Comfy"
+ :variable-pitch-family "Iosevka Comfy"
+ :variable-pitch-height 1.0
+ :fixed-pitch-family "Iosevka Comfy"
+ :fixed-pitch-height 1.0
+ :bold-weight bold
+ )
+ (tiny
+ :inherit default
+ :default-height 135)
+ (wide
+ :default-height 135
+ :default-family "Iosevka Comfy Wide"
+ :fixed-pitch-family "Iosevka Comfy Wide"
+ :variable-pitch-family "Iosevka Comfy Wide Motion Duo")
+ (prot
+ :default-family "Iosevka Comfy Wide Motion"
+ :default-height 130
+ :default-weight medium
+ :fixed-pitch-family "Iosevka Comfy Wide Motion"
+ :variable-pitch-family "Iosevka Comfy Wide Duo"
+ :bold-weight extrabold)
+ (mono
+ :default-height 130
+ :default-family "monospace"
+ :fixed-pitch-family "monospace"
+ :variable-pitch-family "Baskerville"
+ :variable-pitch-height 140)
+ (mono-large
+ :inherit mono
+ :default-height 150
+ :variable-pitch-height 160)
+ (mac
+ :default-height 130
+ :default-family "Monaco"
+ :variable-pitch-family "Monaco"
+ :fixed-pitch-family "Monaco")
+ (large
+ :inherit default
+ :default-height 160)
+ (huge
+ :inherit default
+ :default-height 180)
+ (t
+ :default-family "Monospace")))
(set-fontset-font
t 'han
(font-spec :family "Noto Serif CJK JP") nil 'prepend)
-;;; Switching themes
(defun bard/disable-all-themes ()
"disable all active themes."
(interactive)
@@ -85,25 +81,6 @@
(message "Loaded the %s theme" colored-theme-name)
(run-hooks 'bard/after-theme-load-hook)))
-(defun bard/update-ryo-cursor-color ()
- "Update the color variable of `ryo-modal-mode' cursor to match the ef/modus theme."
- (let ((active-theme (car custom-enabled-themes))
- (cursor-color nil))
- (cond
- ((and (fboundp 'ef-themes-with-colors)
- (string-prefix-p "ef-" (symbol-name active-theme)))
- (ef-themes-with-colors
- (setq ryo-modal-cursor-color cursor
- ryo-modal-default-cursor-color cursor)))
- ((and (fboundp 'modus-themes-with-colors)
- (string-prefix-p "modus-" (symbol-name active-theme)))
- (modus-themes-with-colors
- (setq ryo-modal-cursor-color cursor
- ryo-modal-default-cursor-color cursor)))
- (t (setq cursor-color "red"))
- (setq ryo-modal-cursor-color cursor-color
- ryo-modal-default-cursor-color cursor-color))))
-
(defvar my-last-cursor-type nil)
(defun bard/update-cursor-type ()
diff --git a/bard-elisp/bard-window.el b/bard-elisp/bard-window.el
index 3e30a2e..220143a 100644
--- a/bard-elisp/bard-window.el
+++ b/bard-elisp/bard-window.el
@@ -76,8 +76,6 @@ use in `display-buffer-alist'."
(and (not (derived-mode-p 'message-mode 'text-mode))
(derived-mode-p 'eshell-mode 'shell-mode 'term-mode 'comint-mode 'fundamental-mode)))))
-;; taken from https://github.com/hylophile/.files/blob/1f3f01e4e25b00f7b61eca286fcf4f865885090c/.config/doom/config.org#fancy-tab-bar
-
(defun hy/tab-bar-format-align-center ()
"Align the rest of tab bar items centered."
(let* ((rest (cdr (memq 'hy/tab-bar-format-align-center tab-bar-format)))
diff --git a/bard-elisp/bard-writing.el b/bard-elisp/bard-writing.el
index 8138b1a..2ab9c0a 100644
--- a/bard-elisp/bard-writing.el
+++ b/bard-elisp/bard-writing.el
@@ -6,29 +6,20 @@
(defvar bard/consult--source-notes
`(:name "Note Buffers"
- :narrow ?n
- :category buffer
- :face consult-buffer
- :history buffer-name-history
- :items ,(lambda ()
- (mapcar #'buffer-name
- (seq-filter
- (lambda (buf)
- (string-prefix-p "[Note]" (buffer-name buf)))
- (beframe-buffer-list))))
- :action ,#'switch-to-buffer
- :state ,#'consult--buffer-state)
+ :narrow ?n
+ :category buffer
+ :face consult-buffer
+ :history buffer-name-history
+ :items ,(lambda ()
+ (mapcar #'buffer-name
+ (seq-filter
+ (lambda (buf)
+ (string-prefix-p "[Note]" (buffer-name buf)))
+ (beframe-buffer-list))))
+ :action ,#'switch-to-buffer
+ :state ,#'consult--buffer-state)
"Consult source for note buffers (limited to beframe buffers).")
-
-(defun bard/find-notes-file ()
- (interactive)
- (consult-find "~/Notes/denote"))
-
-(defun bard/search-notes-directory ()
- (interactive)
- (consult-grep "~/Notes/denote"))
-
(defun bard/consult-buffer-notes ()
"Show `consult-buffer` limited to buffers starting with [Note]."
(interactive)
@@ -40,37 +31,21 @@
(ibuffer nil "*Ibuffer-Notes*"
'((name . "^\\[Note\\]"))))
-(defun denote-sequence-region ()
- "Call `denote-sequence' and insert therein the text of the active region.
+(defun bard/find-notes-file ()
+ (interactive)
+ (consult-find "~/Notes/denote"))
-Note that, currently, `denote-save-buffers' and
-`denote-kill-buffers' are NOT respected. The buffer is not
-saved or killed at the end of `denote-sequence-region'."
- (declare (interactive-only t))
+(defun bard/search-notes-directory ()
(interactive)
- (if-let* (((region-active-p))
- ;; We capture the text early, otherwise it will be empty
- ;; the moment `insert' is called.
- (text (buffer-substring-no-properties (region-beginning) (region-end))))
- (progn
- (let ((denote-ignore-region-in-denote-command t)
- ;; FIXME: Find a way to insert the region before the buffer is
- ;; saved/killed by the creation command.
- (denote-save-buffers nil)
- (denote-kill-buffers nil))
- (call-interactively 'denote-sequence))
- (push-mark (point))
- (insert text)
- (run-hook-with-args 'denote-region-after-new-note-functions (mark) (point)))
- (call-interactively 'denote-sequence)))
+ (consult-grep "~/Notes/denote"))
(defvar bard/class-dirs
- '(("ANTH 204" . "~/Documents/dox/Uni/FALL2025-ANTH 204/")
- ("CHEM 201" . "~/Documents/dox/Uni/FALL2025-CHEM 201/")
- ("CHEM 207" . "~/Documents/dox/Uni/FALL2025-CHEM 207/")
- ("ENGL 105" . "~/Documents/dox/Uni/FALL2025-ENGL 105/")
- ("ENGR 101" . "~/Documents/dox/Uni/FALL2025-ENGR 101/")
- ("ENGR 110" . "~/Documents/dox/Uni/FALL2025-ENGR 110/"))
+ '(("ANTH 204" . "~/Documents/Uni/FALL2025-ANTH 204/")
+ ("CHEM 201" . "~/Documents/Uni/FALL2025-CHEM 201/")
+ ("CHEM 207" . "~/Documents/Uni/FALL2025-CHEM 207/")
+ ("ENGL 105" . "~/Documents/Uni/FALL2025-ENGL 105/")
+ ("ENGR 101" . "~/Documents/Uni/FALL2025-ENGR 101/")
+ ("ENGR 110" . "~/Documents/Uni/FALL2025-ENGR 110/"))
"Mapping of class names to their document directories.")
(defvar bard/uni-notes-file "~/Notes/denote/uni.org"
@@ -96,27 +71,6 @@ saved or killed at the end of `denote-sequence-region'."
(with-selected-window dired-window
(dired dir)))))
-;; (defun bard/jump-to-class-new-frame (class)
-;; "Open CLASS notes and dir in a new frame titled after CLASS."
-;; (interactive
-;; (list (completing-read "Class: " (mapcar #'car bard/class-dirs))))
-;; (let* ((dir (cdr (assoc class bard/class-dirs)))
-;; ;; make a new frame with title
-;; (frame (make-frame `((name . ,class)))))
-;; (select-frame-set-input-focus frame)
-;; (delete-other-windows)
-;; (let ((notes-window (selected-window))
-;; (dired-window (split-window-right)))
-;; ;; open notes file and jump to heading
-;; (with-selected-window notes-window
-;; (find-file bard/uni-notes-file)
-;; (widen)
-;; (goto-char (point-min))
-;; (search-forward class nil nil))
-;; ;; open dired in right window
-;; (with-selected-window dired-window
-;; (dired dir)))))
-
(defun bard/jump-to-class-new-frame (class)
"Open CLASS notes and dir in a new frame titled after CLASS, even with beframe."
(interactive
@@ -141,15 +95,21 @@ saved or killed at the end of `denote-sequence-region'."
(global-set-key (kbd "C-c U") #'bard/jump-to-class-new-frame)
(defun bard/denote-todo-template ()
- "Return string for daily tasks heading in `denote-journal' entries"
- (format "* Tasks for %s\n\n* Notes for today"
- (format-time-string "%Y-%m-%d (%a)")))
+ "Return string for daily tasks heading in `denote-journal' entries."
+ (with-temp-buffer
+ (org-mode)
+ (insert (format "* Tasks for %s\n** Время я потратил бездельничая\n\n* Notes for today\n\n"
+ (format-time-string "%Y-%m-%d (%a)")))
+ (let ((org-clock-clocktable-default-properties
+ '(:scope file :maxlevel 3 :link nil :compact t)))
+ (org-clock-report))
+ (buffer-string)))
;; Taken from: https://stackoverflow.com/a/75314192
(defun add-multiple-into-list (lst items)
- "Add each item from ITEMS into LST."
- (dolist (item items)
- (add-to-list lst item)))
+ "Add each item from ITEMS into LST."
+ (dolist (item items)
+ (add-to-list lst item)))
(defun bard/cdlatex-add-math-symbols ()
"Add functions into list."
@@ -167,5 +127,4 @@ saved or killed at the end of `denote-sequence-region'."
(electric-pair-local-mode t)
(bard/cdlatex-add-math-symbols))
-
(provide 'bard-writing)