Emacs: Use auto-mode-alist instead of find-file-hook when it makes sense
parent
d67e3ded56
commit
178977c88a
|
@ -161,7 +161,6 @@
|
||||||
|
|
||||||
;;; Mail with Mutt support.
|
;;; Mail with Mutt support.
|
||||||
(add-hook 'mail-mode-hook 'mail-text)
|
(add-hook 'mail-mode-hook 'mail-text)
|
||||||
(add-to-list 'auto-mode-alist '("/tmp/mutt-.*" . mail-mode))
|
|
||||||
(defun mutt-backup-buffer ()
|
(defun mutt-backup-buffer ()
|
||||||
"Create a copy of the current buffer.
|
"Create a copy of the current buffer.
|
||||||
This is useful for recovery in case Mutt hangs before sending the
|
This is useful for recovery in case Mutt hangs before sending the
|
||||||
|
@ -169,12 +168,12 @@ e-mail."
|
||||||
(when (not (boundp 'mutt-backup))
|
(when (not (boundp 'mutt-backup))
|
||||||
(set (make-local-variable 'mutt-backup) (make-temp-file (concat (buffer-name) "-"))))
|
(set (make-local-variable 'mutt-backup) (make-temp-file (concat (buffer-name) "-"))))
|
||||||
(copy-file buffer-file-name mutt-backup t))
|
(copy-file buffer-file-name mutt-backup t))
|
||||||
(defun mutt-check-buffer ()
|
(defun mutt-edit ()
|
||||||
(when (string-match "/tmp/mutt-.*" (buffer-file-name))
|
(mail-mode)
|
||||||
;; Just like magit commits.
|
;; Just like magit commits.
|
||||||
(when (require 'with-editor nil t) (with-editor-mode))
|
(when (require 'with-editor nil t) (with-editor-mode))
|
||||||
(add-hook 'after-save-hook 'mutt-backup-buffer nil t)))
|
(add-hook 'after-save-hook 'mutt-backup-buffer nil t))
|
||||||
(add-hook 'find-file-hook 'mutt-check-buffer)
|
(add-to-list 'auto-mode-alist '("/tmp/mutt-.*" . mutt-edit))
|
||||||
|
|
||||||
;;; Makefile
|
;;; Makefile
|
||||||
(with-eval-after-load 'make-mode (require 'init-makefile))
|
(with-eval-after-load 'make-mode (require 'init-makefile))
|
||||||
|
@ -267,11 +266,10 @@ e-mail."
|
||||||
;;; Web forms.
|
;;; Web forms.
|
||||||
;;; Remove auto-fill in web edits because wikis and forums do not like it.
|
;;; Remove auto-fill in web edits because wikis and forums do not like it.
|
||||||
;;; This works for qutebrowser, but may need changes for other browsers.
|
;;; This works for qutebrowser, but may need changes for other browsers.
|
||||||
(defun browser-check-buffer ()
|
(defun browser-edit ()
|
||||||
(when (string-match (concat (getenv "BROWSER") "-editor-*") (buffer-name))
|
(when (require 'with-editor nil t) (with-editor-mode))
|
||||||
(when (require 'with-editor nil t) (with-editor-mode))
|
(auto-fill-mode -1))
|
||||||
(auto-fill-mode -1)))
|
(add-to-list 'auto-mode-alist `(,(concat (getenv "BROWSER") "-editor-*") . browser-edit))
|
||||||
(add-hook 'find-file-hook 'browser-check-buffer)
|
|
||||||
|
|
||||||
;;; Wgrep
|
;;; Wgrep
|
||||||
(nconc package-selected-packages '(wgrep-helm wgrep-pt))
|
(nconc package-selected-packages '(wgrep-helm wgrep-pt))
|
||||||
|
|
|
@ -35,8 +35,7 @@ Useful when bound to a key opposed to `beginning-of-defun'."
|
||||||
(defun call-process-to-string (program &rest args)
|
(defun call-process-to-string (program &rest args)
|
||||||
"Call PROGRAM with ARGS and return output."
|
"Call PROGRAM with ARGS and return output."
|
||||||
(with-output-to-string
|
(with-output-to-string
|
||||||
(with-current-buffer
|
(with-current-buffer standard-output
|
||||||
standard-output
|
|
||||||
(apply 'call-process program nil t nil args))))
|
(apply 'call-process program nil t nil args))))
|
||||||
|
|
||||||
(defun count-occurences (regex string)
|
(defun count-occurences (regex string)
|
||||||
|
|
Loading…
Reference in New Issue