summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-01-21 23:52:21 +0800
committerJSDurand <mmemmew@gmail.com>2021-01-22 00:01:20 +0800
commit588b6031e152b031be1dee04c7b38938ea7eb706 (patch)
treeed25c53f4e1ece59f97ecbff19cb2325bf01baf3
parent53db9402916822e673b3b49fcba26537e2416b59 (diff)
Regular updates
In the course of configuring Emacs there are numerous changes to make. This is one regular step.
-rw-r--r--basic.el27
-rw-r--r--bongo.el15
-rw-r--r--center-buffer.el13
-rw-r--r--comb/orderless-conf.el18
-rw-r--r--common.el6
-rw-r--r--dashboard.el6
-rw-r--r--gnus-conf.el11
-rw-r--r--ibuffer.el28
-rw-r--r--init.el5
-rw-r--r--modeline.el2
-rw-r--r--org-conf.el10
-rw-r--r--text-conf.el6
-rw-r--r--view-conf.el23
13 files changed, 143 insertions, 27 deletions
diff --git a/basic.el b/basic.el
index 7a53334..191c997 100644
--- a/basic.el
+++ b/basic.el
@@ -211,7 +211,7 @@ I stole from Protesilaos' dotemacs.")
;;; Hide auto-revert-mode
;; The original is auto-revert-mode-text
-(durand-hide-minor-mode auto-revert-mode)
+(durand-hide-minor-mode auto-revert-mode autorevert)
;;; enable all commands
@@ -226,13 +226,38 @@ I stole from Protesilaos' dotemacs.")
(set 'comment-multi-line t)
(set 'comment-style 'multi-line)
+;;; Toggle line numbers
+
+(define-key global-map (vector 'f9) #'durand-display-line-numbers)
+
+;;;###autoload
+(defun durand-display-line-numbers (&optional arg)
+ "Display absolute line numbers or not.
+With a positive ARG, display in relative style.
+With a negative ARG, display in visual style.
+With zero ARG, disable line numbers.
+See `display-line-numbers' for details."
+ (interactive "P")
+ (setq display-line-numbers
+ (cond
+ ((null arg) (not display-line-numbers))
+ ((> (prefix-numeric-value arg) 0) 'relative)
+ ((< (prefix-numeric-value arg) 0) 'visual))))
+
;;; Windows
(define-key global-map (vector ?\s-o) #'other-window)
(define-key global-map (vector ?\s-&) #'delete-other-windows)
+(define-key global-map (vector ?\s-é) #'split-window-below)
+;; The following binds the key ?\s-" represented as a number, since
+;; otherwise it would be interpreted as a string quote.
+(define-key global-map (vector 8388642) #'split-window-right)
(define-key global-map (vector ?\s-à) #'delete-window)
(define-key global-map (vector ?\C-+) #'enlarge-window)
(define-key global-map (vector ?\s-f) #'find-file)
+(define-key global-map (vector ?\s-F) #'find-file-other-window)
+(define-key global-map (vector ?\s-d) #'dired)
+(define-key global-map (vector ?\s-D) #'dired-other-window)
(define-key global-map (vector ?\s-v) #'durand-focus-completion-or-minibuffer)
;;; Package management
diff --git a/bongo.el b/bongo.el
index 623317a..1835973 100644
--- a/bongo.el
+++ b/bongo.el
@@ -21,10 +21,18 @@
(setq bongo-mode-line-indicator-mode nil)
(setq bongo-enabled-backends '(mpv))
(setq bongo-seek-electric-mode nil)
- (setf bongo-custom-backend-matchers
- '((mpv local-file "webm" "m4a")))
+ ;; I still don't know how to make bongo automatically play a YouTube
+ ;; link.
+ (setq bongo-custom-backend-matchers
+ '((mpv local-file "webm" "m4a")
+ (mpv "https:" "youtube")))
(setq-default bongo-next-action 'durand-bongo-play-next-or-first)
+ ;; Bongo info path
+
+;;;###autoload
+ (add-to-list 'Info-directory-list (expand-file-name "bongo/" package-dir))
+
;;;###autoload
(defvar durand-bongo-music-dir nil
"Directories to store my songs.
@@ -53,6 +61,7 @@ This is used since my music directories used to contain symbolic links.")
;; collect attr)
))
+ (define-key global-map (vector ?\C-c ?b) #'bongo)
(define-key bongo-playlist-mode-map [?n] #'bongo-next-object-line)
(define-key bongo-playlist-mode-map [?p] #'bongo-previous-object-line)
(define-key bongo-playlist-mode-map [?j] #'durand-bongo-save-playlist)
@@ -343,7 +352,7 @@ insert an action track at point."
(bongo-mark-current-track-line-as-played))
(durand-bongo-next-or-first n)
(bongo-start)))))
-
+
;;;###autoload
(defun durand-bongo-previous-or-last (&optional n)
"Make the previous track current in the nearest playlist buffer.
diff --git a/center-buffer.el b/center-buffer.el
index 69d4a90..42c38ef 100644
--- a/center-buffer.el
+++ b/center-buffer.el
@@ -13,6 +13,15 @@
"The width of the body.")
;;;###autoload
+(defun center-buffer-toggle ()
+ "Toggle the centering of the buffer."
+ (interactive)
+ (cond
+ ((car (window-margins (selected-window)))
+ (center-buffer-off))
+ ((center-buffer-on))))
+
+;;;###autoload
(defun center-buffer-on ()
"Center the buffer."
(interactive)
@@ -30,9 +39,5 @@
(interactive)
(set-window-margins (selected-window) 0 0))
-
-
-
-
(provide 'center-bufrfer)
;;; center-bufrfer.el ends here.
diff --git a/comb/orderless-conf.el b/comb/orderless-conf.el
index 8af75e4..2d669a4 100644
--- a/comb/orderless-conf.el
+++ b/comb/orderless-conf.el
@@ -1,15 +1,15 @@
;;; -*- lexical-binding: t; -*-
(use-package "orderless" 'orderless
- (setq completion-styles '(orderless partial-completion)
- completion-category-defaults nil
- completion-flex-nospace nil
- completion-pcm-complete-word-inserts-delimiters t
- completion-show-help nil
- completion-ignore-case t
- read-file-name-completion-ignore-case t
- read-buffer-completion-ignore-case t
- resize-mini-windows t)
+ (setq completion-styles '(substring orderless partial-completion))
+ (setq completion-category-defaults nil)
+ (setq completion-flex-nospace nil)
+ (setq completion-pcm-complete-word-inserts-delimiters t)
+ (setq completion-show-help nil)
+ (setq completion-ignore-case t)
+ (setq read-file-name-completion-ignore-case t)
+ (setq read-buffer-completion-ignore-case t)
+ (setq resize-mini-windows t)
(setq orderless-component-separator " +"
orderless-matching-styles '(orderless-prefixes
diff --git a/common.el b/common.el
index b19a85a..702124f 100644
--- a/common.el
+++ b/common.el
@@ -67,8 +67,10 @@
;;; Hide some minor mode from the mode line display.
;;;###autoload
-(defmacro durand-hide-minor-mode (minor)
- "Hide MINOR from the mode line."
+(defmacro durand-hide-minor-mode (minor &optional to-require)
+ "Hide MINOR from the mode line.
+Require TO-REQUIRE so that we don't have errors."
+ (cond (to-require (require to-require)))
`(setcdr (assq ',minor minor-mode-alist) (list "")))
(provide 'common)
diff --git a/dashboard.el b/dashboard.el
index a8f753f..e2e3669 100644
--- a/dashboard.el
+++ b/dashboard.el
@@ -17,10 +17,11 @@
(with-current-buffer dashboard
(let ((image (create-image "~/.doom.d/banners/default.png")))
(insert
+ (make-string 3 10)
(center-string-in-width
(propertize " " 'display image 'rear-nonsticky '(display))
(round (- (window-body-width)
- (* (car (image-size image)) 0.6))))))
+ (* (car (image-size image)) 1))))))
(newline 5)
(insert
(center-string-in-width
@@ -28,7 +29,8 @@
(window-body-width)))
(read-only-mode 1)
(set 'mode-line-format
- '("%e" (:eval (modeline-format-dashboard)))))))
+ '("%e" (:eval (modeline-format-dashboard))))
+ (view-mode 1))))
dashboard))
(set 'initial-buffer-choice #'dashboard)
diff --git a/gnus-conf.el b/gnus-conf.el
index f1b0b2c..d36386d 100644
--- a/gnus-conf.el
+++ b/gnus-conf.el
@@ -15,6 +15,13 @@
;; (nnimap-server-port 143))
))
+;; Update by mu4e
+
+(declare-function #'mu4e-update-mail-and-index "mu4e" (RUN-IN-BACKGROUND))
+
+(define-key gnus-group-mode-map (vector 117) #'mu4e-update-mail-and-index)
+(define-key global-map (vector ?\C-c ?g) 'gnus)
+
(setq gnus-ignored-from-addresses "mmemmew@gmail.com")
(setq send-mail-function #'smtpmail-send-it)
@@ -90,12 +97,14 @@
(setq gnus-thread-hide-subtree nil)
(setq gnus-ignored-from-addresses "mmemmew\\.com")
-;;; move between topics
+;; move between topics
(define-key gnus-group-mode-map [?\M-n] 'gnus-topic-goto-next-topic)
(define-key gnus-group-mode-map [?\M-p] 'gnus-topic-goto-previous-topic)
+;; exiting
(define-key gnus-group-mode-map (vector ?q) #'bury-buffer)
+(define-key gnus-group-mode-map (vector ?x) #'gnus-group-exit)
;;; agent settings
diff --git a/ibuffer.el b/ibuffer.el
index 2033bba..c67325e 100644
--- a/ibuffer.el
+++ b/ibuffer.el
@@ -8,10 +8,34 @@
(setq ibuffer-show-empty-filter-groups nil)
-;;; a temporary binding
+;;; Bindings related to buffers
+
+;;;; Quickly switch to the last buffer.
+
+;;;###autoload
+(defun durand-switch-to-last-buffer (&optional arg)
+ "Switch to the last buffer.
+
+The last buffer is given by `other-buffer'.
+
+If ARG is non-nil, then display the last buffer in a new window."
+ (interactive "P")
+ (cond
+ (arg (switch-to-buffer-other-window nil))
+ ((switch-to-buffer nil))))
+
+;;;###autoload
+(defun durand-switch-to-last-buffer-other-window ()
+ "Switch to the last buffer in a new window."
+ (interactive)
+ (switch-to-buffer-other-window nil))
(define-key global-map (vector 24 2) #'ibuffer)
-(define-key global-map (vector ?\s-b) #'ibuffer)
+(define-key global-map (vector ?\s-h) #'ibuffer)
+(define-key global-map (vector ?\s-b) #'switch-to-buffer)
+(define-key global-map (vector ?\s-B) #'switch-to-buffer-other-window)
+(define-key global-map (vector ?\s-n) #'durand-switch-to-last-buffer)
+(define-key global-map (vector ?\s-N) #'durand-switch-to-last-buffer-other-window)
(define-key ibuffer-mode-map (vector ?d) #'ibuffer-do-delete)
(define-key ibuffer-mode-map (vector ?D) #'ibuffer-mark-for-delete)
diff --git a/init.el b/init.el
index 98d0b88..6fe37ad 100644
--- a/init.el
+++ b/init.el
@@ -169,7 +169,7 @@ If FUNCTION-NAME is already a valid function, this won't do anything."
(defalias 'magit 'magit-status)
(magit))
-(define-key global-map (vector 3 103) 'magit)
+(define-key global-map (vector ?\C-x ?g) 'magit)
;;; eww
@@ -190,7 +190,8 @@ If FUNCTION-NAME is already a valid function, this won't do anything."
;;; My simple utilities
(use-package "durand-simple" 'durand-simple
- (define-key global-map (vector ?\C-\M-\s) #'durand-simple-mark-dwim))
+ (define-key global-map (vector ?\C-\M-\s) #'durand-simple-mark-dwim)
+ (define-key global-map (vector ?\C-o) #'durand-simple-open-line))
;;; Searches
diff --git a/modeline.el b/modeline.el
index 46d9080..212db07 100644
--- a/modeline.el
+++ b/modeline.el
@@ -469,7 +469,7 @@ This will be displayed in the mode line."
(concat
(modeline-propertize
(format-mode-line
- "%m"
+ '("%m" global-mode-string)
(cond ((modeline-active-window-p)
'doom-modeline-buffer-major-mode)
(t 'mode-line-inactive)))
diff --git a/org-conf.el b/org-conf.el
index 1104a2b..aafbc8d 100644
--- a/org-conf.el
+++ b/org-conf.el
@@ -370,6 +370,16 @@ in Lisp code use `org-set-tags' instead."
;; ((durand-agenda-command-sections-time)))
))
+;;; elisp in link confirmation
+
+(setq org-link-elisp-confirm-function 'y-or-n-p)
+
+;;; agenda window setup
+
+(setq org-agenda-window-setup 'other-tab)
+;; The following will be ignored since the above is 'other-tab.
+(setq org-agenda-restore-windows-after-quit t)
+
;;; novel addresses
;;;###autoload
(defvar durand-novel-addresses-regexp '("uukanshu"
diff --git a/text-conf.el b/text-conf.el
index 1fe9696..fdecb38 100644
--- a/text-conf.el
+++ b/text-conf.el
@@ -2,6 +2,12 @@
(require 'text-mode)
+(declare-function #'center-buffer-on "center-buffer" nil)
+(declare-function #'center-buffer-off "center-buffer" nil)
+(declare-function #'center-buffer-toggle "center-buffer" nil)
+
+(define-key text-mode-map (vector 'f8) #'center-buffer-toggle)
+
;;;###autoload
(defvar insert-section-heading-history nil
"The history of inserted section heading strings")
diff --git a/view-conf.el b/view-conf.el
index 945276f..4d4ff00 100644
--- a/view-conf.el
+++ b/view-conf.el
@@ -95,3 +95,26 @@ If ARG is '(16), view the battery information."
(define-key view-mode-map (vector ?j) #'View-scroll-line-forward)
(define-key view-mode-map (vector ?k) #'View-scroll-line-backward)
+
+;;; Convert downloaded videos from youtube to the URL again and copy
+;;; the result.
+
+;;;###autoload
+(defun durand-convert-youtube-video-to-url (video-name)
+ "Convert VIDEO-NAME to its original url."
+ (interactive (list (read-string "Video name: ")))
+ (cond
+ ((string-match "\\.[^.]+$" video-name)
+ ;; with extension
+ (kill-new
+ (concat
+ "https://www.youtube.com/watch?v="
+ (substring-no-properties
+ video-name
+ (- (match-beginning 0) 11)
+ (match-beginning 0)))))
+ (t
+ ;; no extension
+ (kill-new
+ (concat "https://www.youtube.com/watch?v="
+ (substring-no-properties video-name -11))))))