;;; ymh-common.el --- Some common functions -*- lexical-binding: t; -*- ;;; Commentary: ;; This file contains some common code. ;;; Code: (defun ymh/prev-window () "Go to the previous window using `other-window'." (interactive) (other-window -1)) (defun ymh/reset-coq-windows (&optional prefix) "Resets the Goal and Response windows." (interactive (list (when current-prefix-arg (prefix-numeric-value current-prefix-arg)))) (message prefix) (cond ((and prefix (> prefix 0)) (other-frame 1) (delete-other-windows) (split-window-below) (switch-to-buffer "*goals*") (other-window 1) (switch-to-buffer "*response*") (other-frame 1)) (t (delete-other-windows) (split-window-right) (other-window 1) (switch-to-buffer "*goals*") (split-window-below) (other-window 1) (switch-to-buffer "*response*") (other-window 1)))) (defun ymh/pass (query) "Return the password as a string from QUERY." (s-trim (shell-command-to-string (concat "pass show " query)))) (defun ymh/apply-theme (appearance) "Load theme, taking current system APPEARANCE into consideration." (mapc #'disable-theme custom-enabled-themes) (pcase appearance ('light (load-theme 'modus-operandi-tinted t)) ('dark (load-theme 'modus-vivendi-tinted t)) ;;('light (load-theme 'ef-spring t)) ;;('dark (load-theme 'ef-dark t)) ) (ymh-modus-theme-apply-customisations)) (defadvice load-theme (before theme-dont-propagate activate) (mapc #'disable-theme custom-enabled-themes)) (defun ymh/electric-space () (interactive) (let ((sentence-end-double-space nil)) (if (looking-back (sentence-end)) (insert "\n") (self-insert-command 1)))) ;;; Stefan Monnier: It is the opposite of fill-paragraph. (defun ymh/unfill-paragraph (&optional region) "Takes a multi-line paragraph and makes it into a single line of text." (interactive (progn (barf-if-buffer-read-only) '(t))) (let ((fill-column (point-max)) ;; This would override `fill-column' if it's an integer. (emacs-lisp-docstring-fill-column t)) (fill-paragraph nil region))) (provide 'ymh-common) ;;; ymh-common.el ends here