summaryrefslogtreecommitdiff
path: root/lisp/mk.el
blob: 748f7b0d41ededb3e91b7bb1469a26b766265eab (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; Code:

(defun mk/kill-other-buffers ()
  "Kill all other buffers."
  (interactive)
  (mapc (lambda (buffer)
          (when (and (buffer-file-name buffer) (not (eq buffer (current-buffer))))
            (kill-buffer buffer)))
        (buffer-list)))

(defun mk/format-xml ()
  (interactive)
  (shell-command-on-region 1 (point-max) "xmllint --format -" (current-buffer) t)
  )

;; Copy the entire buffer.
(defun mk/copy-all ()
    "Copy entire buffer to clipboard."
    (interactive)
    (clipboard-kill-ring-save (point-min) (point-max)))

(defun mk/create-directory ()
  "Create a directory and refresh neotree."
  (interactive)
  (call-interactively #'make-directory)
  (other-window -1))
(bind-key* (kbd "C-c d n") 'mk/create-directory)

(defun mk/delete-file ()
  "Delete a file and refresh neotree."
  (interactive)
  (call-interactively #'delete-file))
(bind-key* (kbd "C-c f d") 'mk/delete-file)

(defun mk/create-file (filename)
  "Create a file and refresh neotree.  FILENAME File to create."
  (interactive (list (read-file-name "Enter your file name:  " nil nil nil (file-name-nondirectory ""))))
  (make-empty-file filename)
  (find-file filename))

(bind-key* (kbd "C-c f n") 'mk/create-file)



(defun mk/delete-directory ()
  "Delete a file and refresh neotree."
  (interactive)
  (call-interactively #'delete-directory))
(bind-key* (kbd "C-c d d") 'mk/delete-directory)


;; source: http://steve.yegge.googlepages.com/my-dot-emacs-file
(defun mk/rename-file (new-name)
  "Renames both current buffer and file it's visiting to NEW-NAME."
  (interactive "sNew name: ")
  (let ((name (buffer-name))
        (filename (buffer-file-name)))
    (if (not filename)
        (message "Buffer '%s' is not visiting a file!" name)
      (if (get-buffer new-name)
          (message "A buffer named '%s' already exists!" new-name)
        (progn
          (rename-file filename new-name 1)
          (rename-buffer new-name)
          (set-visited-file-name new-name)
          (set-buffer-modified-p nil)
          ;(neotree-show)
          ;(neotree-refresh)
          (other-window -1))))))
(bind-key* (kbd "C-c f r") 'mk/rename-file)

(defun mk/meow ()
  (interactive)
  (print "Meow!"))

(provide 'mk)
;;; mk.el ends here