aboutsummaryrefslogtreecommitdiff
path: root/config/emacs/emacs.d/lisp/init-misc.el
blob: 1fb4f2d3b1a17cb3f6f4ab085a1f0797a4239a93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; init-misc --- Miscellaneous Configuration
;;; Commentary:
;;; Misc config - yet to be placed in separate files
;;; Code:

(defvar f)
(defvar multiple-cursors)
(use-package f)

(fset 'yes-or-no-p 'y-or-n-p)

(add-hook 'prog-mode-hook 'goto-address-prog-mode)
(setq goto-address-mail-face 'link)

(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
(add-hook 'after-save-hook 'sanityinc/set-mode-for-new-scripts)

(defun sanityinc/set-mode-for-new-scripts ()
  "Invoke `normal-mode' if this file is a script and in `fundamental-mode'."
  (and
   (eq major-mode 'fundamental-mode)
   (>= (buffer-size) 2)
   (save-restriction
     (widen)
     (string= "#!" (buffer-substring (point-min) (+ 2 (point-min)))))
   (normal-mode)))

(add-to-list 'auto-mode-alist '("Procfile" . 'conf-mode))

(use-package multiple-cursors)

(defun kb/init-window-split ()
  "Initialize automatic split thresholds for X."
  (interactive)
  (if (display-graphic-p)
    (progn
      (if (> (x-display-pixel-width) 1080)
          (setq split-height-threshold 160)
        (setq split-height-threshold 80)))))

(kb/init-window-split)

;; https://trey-jackson.blogspot.com/2010/04/emacs-tip-36-abort-minibuffer-when.html
(defun stop-using-minibuffer ()
  "Kill the minibuffer."
  (when (and (>= (recursion-depth) 1) (active-minibuffer-window))
    (abort-recursive-edit)))

(add-hook 'mouse-leave-buffer-hook #'stop-using-minibuffer)

;; unset goal column
;; I don't really have a use for this
(unbind-key (kbd "C-x C-n") 'global-map)

(provide 'init-misc)
;;; init-misc.el ends here