diff options
-rw-r--r-- | outline-conf.el | 76 | ||||
-rw-r--r-- | view-conf.el | 8 |
2 files changed, 81 insertions, 3 deletions
diff --git a/outline-conf.el b/outline-conf.el new file mode 100644 index 0000000..e55dafb --- /dev/null +++ b/outline-conf.el @@ -0,0 +1,76 @@ +;;; outline-conf.el --- Configurations for outline -*- lexical-binding: t; -*- + +;; Copyright (C) 2021 李俊緯 + +;; Author: 李俊緯 <mmemmew@gmail.com> +;; Keywords: convenience, files, languages, maint, matching, outlines, 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 <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; My configurations for `outline-minor-mode'. + +;;; Code: + +(require 'outline) + +;;;###autoload +(defvar durand-outline-regexp-alist nil + "An alist that associates regular expressions with major modes +that enable `outline-minor-mode'.") + +(setq durand-outline-regexp-alist + (list (cons 'emacs-lisp-mode + (rx-to-string + '(seq bol (>= 3 ";") (syntax ?-)) t)))) + +;;;###autoload +(defvar durand-outline-blocklist (list 'org-mode 'outline-mode) + "The list of major modes in which one should not use +`outline-minor-mode'.") + +;;;###autoload +(defun durand-maybe-enable-outline () + "Enable `outline-minor-mode' if appropriate." + (interactive) + (cond + ((apply #'derived-mode-p durand-outline-blocklist) + (user-error "Should not use `outline-minor-mode' with %S" + major-mode)) + ((null outline-minor-mode) + (let ((regexp (cdr-safe (assq major-mode durand-outline-regexp-alist)))) + (cond + (regexp + (setq-local outline-regexp regexp)))) + (outline-minor-mode 1) + (message "`outline-minor-mode' enabled")) + (t + (outline-minor-mode -1) + (message "`outline-minor-mode' disabled")))) + +(setq outline-minor-mode-highlight 'override) +(setq outline-minor-mode-cycle t) + +(define-key outline-minor-mode-map (vector 3 ?\C-n) #'outline-next-visible-heading) +(define-key outline-minor-mode-map (vector 3 ?\C-p) #'outline-previous-visible-heading) +(define-key outline-minor-mode-map (vector 3 ?\C-f) #'outline-forward-same-level) +(define-key outline-minor-mode-map (vector 3 2) #'outline-backward-same-level) +(define-key outline-minor-mode-map (vector 3 1) #'outline-show-all) +(define-key outline-minor-mode-map (vector 3 ?\C-o) #'outline-hide-other) +(define-key outline-minor-mode-map (vector 3 ?\C-u) #'outline-up-heading) + + +(provide 'outline-conf) +;;; outline-conf.el ends here diff --git a/view-conf.el b/view-conf.el index ae53f1a..d17bd6c 100644 --- a/view-conf.el +++ b/view-conf.el @@ -1,5 +1,6 @@ ;;; view-conf.el --- My configurations to view things -*- lexical-binding: t; -*- +;;; View tmeperatures or timers ;;;###autoload (defun durand-view-timers-or-temps (&optional arg) "View the list of timers or view the CPU temperature info. @@ -21,7 +22,7 @@ If ARG is '(16), view the battery information." connected battery-temp) (with-temp-buffer -;;; NOTE: First fans information +;; NOTE: First fans information (insert (funcall (plist-get (car (auth-source-search :host "local-computer")) :secret))) @@ -37,7 +38,7 @@ If ARG is '(16), view the battery information." cpu-die-temperature (progn (re-search-forward "temperature: \\([[:digit:]]+\\.[[:digit:]]+\\)" nil t) (string-to-number (match-string 1)))) -;;; NOTE: Now battery charge information +;; NOTE: Now battery charge information (erase-buffer) (call-process "system_profiler" nil t nil "SPPowerDataType") @@ -56,7 +57,7 @@ If ARG is '(16), view the battery information." (setf condition (match-string-no-properties 1)) (re-search-forward "Connected: \\(.+\\)$" nil t) (setf connected (match-string-no-properties 1)) -;;; NOTE: Now battery temperature +;; NOTE: Now battery temperature (erase-buffer) (call-process "ioreg" nil t nil "-n" "AppleSmartBattery" "-r") (goto-char (point-min)) @@ -106,6 +107,7 @@ If ARG is '(16), view the battery information." (define-key map (vector ?c) #'calendar) (define-key map (vector ?r) #'choose-recent-file) (define-key map (vector ?n) #'novel) + (define-key map (vector ?O) #'durand-maybe-enable-outline) (define-key map (vector ?w) #'durand-eww-map) map) "The keymap that is related to my custom functions about viewing.") |