aboutsummaryrefslogtreecommitdiffstats
path: root/.emacs.d/lisp/et-utils.el
blob: af5bdbd03b875d527f0f51c10b324a83c95410ef (plain) (blame)
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
;;; et-utils.el --- Utilities for my Emacs configuration -*- lexical-binding: t; -*-
;;
;;; Commentary:
;;
;;; Code:

(defun et-is-desktop-p ()
  "Check if the current system is my desktop system."
  (string-match-p "desktop" (system-name)))

(defun et-insert-elisp-template (summary)
  "Insert a elisp template into the buffer.

SUMMARY will be inserted into the header docstring
as the file summary."
  (interactive (list (read-string "summary: ")))
  (let ((move-to-center-of-code-section (lambda () (forward-line -3)))
	(get-current-file-name (lambda () (file-name-sans-extension (file-name-nondirectory buffer-file-name))))
	(get-module-template (lambda (module-name summary)
			       (format ";;; %s.el --- %s -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:



(provide '%s)
;;; %s.el ends here" module-name summary module-name module-name))))
    (if (not (buffer-file-name))
	(message "No file visited.")
      (progn
	(insert (funcall get-module-template (funcall get-current-file-name) summary))
	(funcall move-to-center-of-code-section)))))

(defun open-init-file ()
  "Open the Emacs init file."
  (interactive)
  (find-file user-init-file)
  (cd (file-name-directory user-init-file)))

(global-set-key (kbd "C-c i") 'open-init-file)

(provide 'et-utils)
;;; et-utils.el ends here