summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-01-19 15:07:57 +0800
committerJSDurand <mmemmew@gmail.com>2021-01-19 15:07:57 +0800
commit4d28d444af32ddf4af5900786473fadacc43e4b1 (patch)
tree1b39232dcbda85cbdad85d64c3e0cb536da267a6
parent82d3a1fcc5c36a48b2a404536f89e1d80c48d999 (diff)
QoL changes.
* bongo.el: Use header-line now. Try to improve the tick. * dired-conf.el: Require dired-x. * elisp.el: Hide Eldoc on the mode line. * text-conf.el (assq): Hide auto-fill-mode on the mode line. * modeline.el (modeline-format-left): Display minor modes information. (modeline-minor-modes-name-len-max): Max length of displayed minor modes. (modeline-format-minor-modes): Display minor modes information. (durand-mouse-minor-mode-menu): Make the default minor mode menu work with my custom mode line. * rime-conf.el ("emacs-rime"): Bind a key to set the input method to rime in the minibuffer, so that I can use this input method to search the buffer, for example.
-rw-r--r--bongo.el40
-rw-r--r--dired-conf.el1
-rw-r--r--elisp.el5
-rw-r--r--modeline.el68
-rw-r--r--rime-conf.el11
-rw-r--r--text-conf.el5
6 files changed, 110 insertions, 20 deletions
diff --git a/bongo.el b/bongo.el
index f5ccd8c..623317a 100644
--- a/bongo.el
+++ b/bongo.el
@@ -3,6 +3,7 @@
(use-package "bongo" 'bongo
(require 'json)
+ (setq bongo-track-mark-icon-file-name nil)
(setq volume-electric-mode nil)
(setq bongo-default-directory (expand-file-name "~/Desktop/Centre/Musique"))
(setq bongo-prefer-library-buffers nil)
@@ -15,8 +16,8 @@
(setq bongo-display-playback-mode-indicator t)
(setq bongo-display-inline-playback-progress nil)
(setq bongo-mark-played-tracks nil)
- (setq bongo-header-line-mode nil)
- (setq bongo-header-line-function nil)
+ (setq bongo-header-line-mode t)
+ (setq bongo-header-line-function #'bongo-default-header-line-function)
(setq bongo-mode-line-indicator-mode nil)
(setq bongo-enabled-backends '(mpv))
(setq bongo-seek-electric-mode nil)
@@ -67,20 +68,6 @@ This is used since my music directories used to contain symbolic links.")
(add-hook 'dired-mode-hook #'durand-bongo-dired-library)
- ;; (map! :map durand-view-map
- ;; [?m] 'bongo
- ;; :map bongo-dired-library-mode-map
- ;; [?\C-j] 'durand-bongo-dired-ivy-find-to-add
- ;; [?\C-c ?n] 'durand-bongo-play-next-or-first
- ;; [?\C-c ?p] 'durand-bongo-play-previous-or-last
- ;; :map bongo-playlist-mode-map
- ;; [?n] 'bongo-next-object-line
- ;; [?p] 'bongo-previous-object-line
- ;; [?j] 'durand-bongo-save-playlist
- ;; "TAB" #'bongo-show
- ;; [?\C-c ?n] 'durand-bongo-play-next-or-first
- ;; [?\C-c ?p] 'durand-bongo-play-previous-or-last)
-
;; seek mode map additions
(define-key bongo-seek-mode-map [?t] 'bongo-seek-to)
@@ -256,6 +243,27 @@ convention is changed."
(advice-add #'bongo-compose-remote-option :override 'durand-bongo-compose-remote-option)
;;;###autoload
+ (defun durand-bongo-mpv-player-tick (player)
+ "Only fetch metadata and length of track if not fetched already.
+
+Afterwards just stop the annoying timer."
+ (let ((timer (bongo-player-get player 'timer)))
+ (cond
+ ;; ((or (not (bongo-player-running-p player))
+ ;; (and (bongo-player-get player 'socket)
+ ;; (not (equal (process-status (bongo-player-get player 'socket))
+ ;; 'open))))
+ ;; (bongo-mpv-player-stop-timer player))
+ ((null (bongo-player-total-time player))
+ (bongo--run-mpv-command player "duration" "get_property" "duration"))
+ ;; ((null (bongo-player-get player 'metadata-fetched))
+ ;; (bongo--run-mpv-command player "metadata" "get_property" "metadata"))
+ (t (bongo-mpv-player-stop-timer player)))))
+
+;;;###autoload
+ ;; (advice-add #'bongo-mpv-player-tick :override #'durand-bongo-mpv-player-tick)
+
+;;;###autoload
(defvar durand-bongo-save-playlist-hist nil
"A variable that holds the history values for saving playlist names.")
diff --git a/dired-conf.el b/dired-conf.el
index 126c67c..861b57e 100644
--- a/dired-conf.el
+++ b/dired-conf.el
@@ -1,6 +1,7 @@
;;; -*- lexical-binding: t; -*-
(require 'dired)
+(require 'dired-x)
(require 'files)
(set 'insert-directory-program "gls")
(set 'dired-listing-switches "-alh --group-directories-first")
diff --git a/elisp.el b/elisp.el
index 507c944..f9a893b 100644
--- a/elisp.el
+++ b/elisp.el
@@ -1,5 +1,10 @@
;;; -*- lexical-binding: t; -*-
+;;; Hide Eldoc in the mode line
+
+;; The original value is eldoc-minor-mode-string
+(setcdr (assq 'eldoc-mode minor-mode-alist) (list ""))
+
;;; fontification of extra keywords in emacs lisp files
(require 'advice)
diff --git a/modeline.el b/modeline.el
index 62e4781..46d9080 100644
--- a/modeline.el
+++ b/modeline.el
@@ -36,7 +36,9 @@
(modeline-spc)
(modeline-format-position)
(modeline-spc)
- (modeline-format-buffer-size)))
+ (modeline-format-buffer-size)
+ (modeline-spc)
+ (modeline-format-minor-modes)))
;;;###autoload
(defun modeline-format-right ()
@@ -360,14 +362,74 @@ W is the width, H is the height of the bar."
(format-mode-line
(file-size-human-readable (string-to-number (format-mode-line "%i")))
(cond
- ((modeline-active-window-p)
- 'mode-line)
+ ((modeline-active-window-p) 'mode-line)
(t 'mode-line-inactive)))
nil
"Buffer size\nmouse-1: Display Line and Column Mode Menu"
mode-line-column-line-number-mode-map))
;;;###autoload
+(defvar modeline-minor-modes-name-len-max 150
+ "The maximal length for the display of minor modes in the mode line.")
+
+;;;###autoload
+(defun modeline-format-minor-modes ()
+ "Display some minor modes information."
+ (declare (pure t) (side-effect-free t))
+ (modeline-propertize
+ (let ((orig
+ (format-mode-line
+ minor-mode-alist
+ (cond
+ ((modeline-active-window-p) 'mode-line)
+ ('mode-line-inactive)))))
+ (cond
+ ((<= (length orig) modeline-minor-modes-name-len-max)
+ orig)
+ ((concat
+ (substring orig 0 (- modeline-minor-modes-name-len-max
+ 3))
+ "..."))))
+ nil
+ "Minor mode
+mouse-1: Display minor mode menu
+mouse-2: Show help for minor mode
+mouse-3: Toggle minor modes"
+ mode-line-minor-mode-keymap))
+
+;;; NOTE: The minor mode menu does not work with my custom mode line.
+
+;;;###autoload
+(defun durand-mouse-minor-mode-menu (event)
+ "Show minor-mode menu for EVENT on minor modes area of the mode line.
+Modified for my custom mode line."
+ (interactive "@e")
+ (let* ((string-obj (nth 4 (car (cdr event))))
+ (str (car string-obj))
+ (str-pos (cdr string-obj))
+ invalid indicator)
+ (cond
+ ((string= str "") (setq invalid t))
+ ((= (aref str str-pos) 32) (setq str-pos (1+ str-pos))))
+ (cond
+ (invalid)
+ ((= (aref str str-pos) 32))
+ (t
+ (let* ((orig str-pos)
+ (start str-pos)
+ (end str-pos))
+ (while (and (>= start 0)
+ (/= (aref str start) 32))
+ (setq start (1- start)))
+ (while (and (< end (length str))
+ (/= (aref str end) 32))
+ (setq end (1+ end)))
+ (setq indicator (substring-no-properties str (1+ start) end))
+ (minor-mode-menu-from-indicator indicator))))))
+
+(advice-add 'mouse-minor-mode-menu :override #'durand-mouse-minor-mode-menu)
+
+;;;###autoload
(defvar modeline-buffer-name-len-max 50
"The maximal length of the name of the buffer to be displayed in the mode line.")
diff --git a/rime-conf.el b/rime-conf.el
index 8bb25fd..d3afae3 100644
--- a/rime-conf.el
+++ b/rime-conf.el
@@ -12,7 +12,8 @@
(use-package "dash.el" 'dash)
(use-package "emacs-rime" 'rime
- (define-key global-map (vector ?\s-i) #'toggle-input-method)
+ (define-key global-map (vector ?\s-i) #'durand-set-input-method)
+ (define-key minibuffer-local-map (vector ?\s-i) #'durand-set-input-method)
(setq rime-librime-root "~/elisp_packages/librime/dist")
(add-to-list 'rime-translate-keybindings "RET")
(add-to-list 'rime-translate-keybindings "[")
@@ -21,6 +22,14 @@
;; rime-show-candidate 'posframe
rime-user-data-dir (expand-file-name "rime" load-file-directory))
+;;;###autoload
+ (defun durand-set-input-method ()
+ "Set the input method to \"rime\" or nil."
+ (interactive)
+ (cond
+ ((string= current-input-method "rime") (set-input-method nil))
+ ((set-input-method "rime"))))
+
;;; HACK: Fix a function
(defun durand-rime-send-keybinding-a ()
"Fix a weird function."
diff --git a/text-conf.el b/text-conf.el
index 1fe9696..46d8fa3 100644
--- a/text-conf.el
+++ b/text-conf.el
@@ -2,6 +2,11 @@
(require 'text-mode)
+;;; Hide auto-fill mode in the mode line.
+
+; The original value is " Fill"
+(setcdr (assq 'auto-fill-function minor-mode-alist) (list ""))
+
;;;###autoload
(defvar insert-section-heading-history nil
"The history of inserted section heading strings")