This repository has been archived by the owner on Jul 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgeneral.el
78 lines (67 loc) · 2.7 KB
/
general.el
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
;;; general.el -*- lexical-binding: t; -*-
;; Time-stamp: <2020-06-13 14:45:46 csraghunandan>
;; Copyright (C) 2016-2020 Chakravarthy Raghunandan
;; Author: Chakravarthy Raghunandan <[email protected]>
;;; Emacs version check
(defmacro >=e (version &rest body)
"Emacs VERSION check wrapper around BODY.
BODY can contain both `if' block (for stuff to execute if emacs
is equal or newer than VERSION) and `else' block (for stuff to
execute if emacs is older than VERSION).
Example:
(>=e \"25.0\"
(defun-compatible-with-25.0)
(defun-not-compatible-in-older-version))"
(declare (indent 2)) ;`if'-style indentation where this macro is used
`(if (version<= ,version emacs-version)
,@body))
(when (eq system-type 'darwin)
(setq source-directory
(concat user-home-directory "/Library/Caches/Homebrew/emacs--git")))
(defun emacs-version-dev (here)
"Display emacs build info and also save it to the kill-ring.
If HERE is non-nil, also insert the string at point."
(interactive "P")
(let ((emacs-build-info
(concat "Emacs version: " (emacs-version) ","
" built using commit " emacs-repository-version ".\n\n"
"./configure options:\n " system-configuration-options "\n\n"
"Features:\n " system-configuration-features "\n")))
(kill-new emacs-build-info)
(message "%s" emacs-build-info)
(when here
(insert emacs-build-info))
emacs-build-info))
;; Quitting emacs via `C-x C-c` or the GUI 'X' button
(setq confirm-kill-emacs #'y-or-n-p)
(setq user-mail-address "[email protected]")
(defun is-mac-p ()
(eq system-type 'darwin))
(defun is-linux-p ()
(eq system-type 'gnu/linux))
(defun is-windows-p ()
(or
(eq system-type 'ms-dos)
(eq system-type 'windows-nt)
(eq system-type 'cygwin)))
(defvar doom--transient-counter 0)
(defmacro add-transient-hook! (hook &rest forms)
"Attaches transient forms to a HOOK.
HOOK can be a quoted hook or a sharp-quoted function (which will be advised).
These forms will be evaluated once when that function/hook is first invoked,
then it detaches itself."
(declare (indent 1))
(let ((append (eq (car forms) :after))
(fn (intern (format "doom-transient-hook-%s" (cl-incf doom--transient-counter)))))
`(when ,hook
(fset ',fn
(lambda (&rest _)
,@forms
(cond ((functionp ,hook) (advice-remove ,hook #',fn))
((symbolp ,hook) (remove-hook ,hook #',fn)))
(unintern ',fn nil)))
(cond ((functionp ,hook)
(advice-add ,hook ,(if append :after :before) #',fn))
((symbolp ,hook)
(add-hook ,hook #',fn ,append))))))
(provide 'general)