summaryrefslogtreecommitdiff
path: root/lisp/init-my-stuff.el
blob: 1c0f084fca2af9adb687aa50eaca7cfc823fbebb (about) (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
78
79
80
(defun my/find-user-init-file ()
  "Edit the `user-init-file', in another window."
  (interactive)
  (find-file-other-window user-init-file))
(global-set-key (kbd "C-c I") 'my/find-user-init-file)

(defun my/new-empty-buffer ()
  "Open a new empty buffer."
  (interactive)
  (let ((buf (generate-new-buffer "untitled")))
    (switch-to-buffer buf)
    (funcall (and initial-major-mode))
    (setq buffer-offer-save t)))
(global-set-key (kbd "C-c n") 'my/new-empty-buffer)

;; http://whattheemacsd.com/key-bindings.el-01.html#disqus_thread
(require 'linum)
(defun my/goto-line-with-feedback ()
  "Show line numbers temporarily, while prompting for the line number input"
  (interactive)
  (let ((line-numbers-off-p (not linum-mode)))
    (unwind-protect
        (progn
          (when line-numbers-off-p
            (linum-mode 1))
          (call-interactively 'goto-line))
      (when line-numbers-off-p
        (linum-mode -1)))))
(global-set-key [remap goto-line] 'my/goto-line-with-feedback)

;; kill current buffer
(global-set-key (kbd "C-x C-k") (lambda ()
                                  (interactive)
                                  (kill-buffer (current-buffer))))

;; delete up to non-whitespace character
(global-set-key (kbd "C-c d") 'hungry-delete-forward)

(defun ssh-dtach (host)
  "Open SSH connection to HOST and start dtach session."
  (interactive)
  (let ((explicit-shell-file-name "dtach")
        (explicit-dtach-args '("-A" "/tmp/emacs.dtach" "-z"
                               "/bin/bash" "--noediting" "-login"))
        (default-directory (format  "/ssh:%s:" host)))
    (shell (format "*ssh %s*" host))))

;; http://blog.vivekhaldar.com/post/4809065853/dotemacs-extract-interactively-change-font-size
(defun my/zoom-in ()
  "Increase font size by 10 points"
  (interactive)
  (set-face-attribute 'default nil
                      :height
                      (+ (face-attribute 'default :height)
                         10)))

(defun my/zoom-out ()
  "Decrease font size by 10 points"
  (interactive)
  (set-face-attribute 'default nil
                      :height
                      (- (face-attribute 'default :height)
                         10)))

;; change font size, interactively
(global-set-key (kbd "C->") 'my/zoom-in)
(global-set-key (kbd "C-<") 'my/zoom-out)

;; easier way to jump to other window
(global-set-key (kbd "M-o") 'other-window)


(defun my/smart-open-line ()
  "Insert an empty line after the current line.
Position the cursor at its beginning, according to the current mode."
  (interactive)
  (move-end-of-line nil)
  (newline-and-indent))

(global-set-key [(shift return)] 'my/smart-open-line)