-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutilities.el
52 lines (45 loc) · 1.72 KB
/
utilities.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
(defsubst icurry (function &rest arguments)
(lexical-let ((function function)
(arguments arguments))
(lambda (&rest more)
(interactive)
(apply function (append arguments more)))))
;;; color these functions like keywords
(font-lock-add-keywords 'emacs-lisp-mode
'(("(\\(icurry\\)[ \t\n\r]" 1 font-lock-keyword-face)))
;; Rounding numbers
(defun get-number-at-point ()
(interactive)
(skip-chars-backward "0123456789.-")
(or (looking-at "[0123456789.-]+")
(error "No number at point"))
(string-to-number (match-string 0)))
(defun round-number-at-point-to-decimals (decimal-count)
(interactive "NDecimal count: ")
(let ((mult (expt 10 decimal-count)))
(replace-match (number-to-string
(/ (fround
(* mult
(get-number-at-point)))
mult)))))
(defun mark-entire-word ()
"Mark the entire word (with superword mode!) under point."
(interactive)
(superword-mode 1)
(backward-word)
(mark-word)
;(kill-ring-save (region-beginning) (region-end))
(superword-mode -1))
(defun cleanup-environment-variables ()
"Completely remove any environment variables that no longer have a value."
(interactive)
(setq process-environment
(-filter (lambda (env-def)
(string-match "=" env-def))
process-environment)))
(defun add-to-ldflags (flag)
"Adds another flag to the LDFLAGS environment variable."
(setenv "LDFLAGS" (s-trim (s-join " " (list (getenv "LDFLAGS") flag)))))
(defun add-to-cppflags (flag)
"Adds another flag to the CPPFLAGS environment variable."
(setenv "CPPFLAGS" (s-trim (s-join " " (list (getenv "CPPFLAGS") flag)))))