-
Notifications
You must be signed in to change notification settings - Fork 1
/
my-vars.el
139 lines (111 loc) · 4.32 KB
/
my-vars.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
;;; my-vars.el --- Common variables used used by all config files
;;
;;; Commentary:
;;
;; These are just a bunch of simple variables I use throughout the
;; rest of the code for controlling optional features.
;;
;;; Code:
(require 'my-utils)
(defvar I-am-emacs-21+ (>= emacs-major-version 21))
;; Lets define which machine I'm on, therefor if I am at work
;; (this of course falls down when logging on remotely via tramp)
(defvar I-am-at-work (string-match "draig" (system-name)))
(defvar I-am-at-home (string-match "danny" (system-name)))
(defvar I-am-on-server (string-match "socrates" (system-name)))
(defvar I-am-on-pixelbook (string-match "penguin" (system-name)))
;; I can probably disable a bunch of stuff for test machines
(defun my-primary-machine-p ()
"Return t if I'm on a primary machine."
(or I-am-at-home I-am-at-work I-am-on-server))
;; Lets set some parameters if we are running as a console or under X
;
; Note these are not useful for --daemon invocations and should now be
; deprecated in favour of "live" tests on window-system
;
(defvar I-am-in-X (eval 'window-system));
(defvar I-am-in-console (not (eval 'window-system)))
(defvar I-am-on-MacOSX (or (string-match "Carbon" (emacs-version))
(string-match "apple-darwin" (emacs-version))))
(defvar I-am-remote (getenv "SSH_TTY"))
(defvar I-am-root (= (user-uid) 0))
;; tweaks some low level vars
(setq read-process-output-max (* 1024 1024))
;; Environment variables the shell may not have set
(when I-am-at-work
(setenv "DEBEMAIL" "[email protected]")
(setenv "DEBFULLNAME" "Alex Bennée")
(setenv "LSP_USE_PLISTS" "1"))
;; Shared regexps
;; DCO Tag snarfing
;;
;; This is used for grabbing Reviewed-by and other such tags from a
;; mailing list. As not all installs of Emacs have the rx-define magic
;; (since ~27.1) we have a manual fall-back with the hand written
;; results of the rx evaluation.
(if (fboundp 'rx-define)
(progn
(rx-define my-bare-dco-tag-rx
(: (any "RSTA") (one-or-more (in alpha "-")) "-by: " ;; tag
(one-or-more (in alpha blank "-.")) ;;name
blank
"<" (one-or-more (not (in ">"))) ">")) ;; email
(rx-define my-dco-tag-rx
(: bol (zero-or-more (in blank)) my-bare-dco-tag-rx))
(rx-define my-msgid-rx
(: "Message-I" (or "d" "D") ": "
"<"
(one-or-more (not (in ">")))
">"))
(defvar my-bare-dco-tag-re
(rx my-bare-dco-tag-rx)
"Regexp to match plain DCO tag")
(defvar my-dco-tag-re
(rx my-dco-tag-rx)
"Regexp to match DCO style tag."))
(defvar my-msgid-re
(rx my-msgid-rx)
"Regexp to match Message-Id")
(defvar my-bare-dco-tag-re
"[AR-T][[:alpha:]-]+-by: [.[:alpha:][:blank:]-]+[[:blank:]]<[^>]+>"
"Regexp to match plain DCO tag")
(defvar my-dco-tag-re
"^[[:blank:]]*[AR-T][[:alpha:]-]+-by: [.[:alpha:][:blank:]-]+[[:blank:]]<[^>]+>"
"Regexp to match DCO style tag.")
(defvar my-msgid-re
"Message-I[Dd]: <[^>]+>"
"Regexp to match Message-Id"))
(defun my-capture-review-tags ()
"Return a list of DCO style tags for current buffer."
(let ((tags))
(save-excursion
(goto-char (point-min))
(while (re-search-forward my-dco-tag-re (point-max) t)
(add-to-list 'tags (match-string-no-properties 0))))
tags))
(defvar my-capture-msgid-re
(rx (: (or "Based-on" "Message-Id" "patchew.org/QEMU")
(or "/" ": ") (zero-or-one "<")
(group (one-or-more (not (in ">" "/" blank cntrl))))))
"Regexp to extract Message-Id from git tags.")
;; This is used for grabbing logins
(defvar my-ssh-login-re
(rx (: (one-or-more alnum)
"@"
(one-or-more (one-or-more alnum)
(zero-or-one "."))))
"Regexp to match host.")
(defun my-capture-login ()
"Return a login string if one exists in the buffer."
(save-excursion
(goto-char (point-min))
(when (re-search-forward my-ssh-login-re (point-max) t)
(match-string-no-properties 0))))
(defvar my-debug-var nil
"A general purpose buffer local debug variable, for debugging.")
(make-variable-buffer-local 'my-debug-var)
(put 'my-debug-var 'permanent-local t)
(defvar my-global-debug-var nil
"A general purpose global debug variable, for debugging.")
(provide 'my-vars)
;;; my-vars.el ends here