forked from vjohansen/emacs-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vj-copy-paste.el
executable file
·85 lines (66 loc) · 2.1 KB
/
vj-copy-paste.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
;; Copy/Paste - The unsolved problem. But files work.
;; Fluxbox on unix
;; ---------------
;;
;; Mod4 is left windows on my setup
;;
;; Mod4 c :ExecCommand ssh hostname "xclip -o > /home/vj/tempfile"
;; tmux on unix
;; ------------
;; (DO NOT use screen. Upgrade!)
;;
;; # <prefix key> C-t
;; bind-key C-t save-buffer ~/tempfile
;; Windows with AutoHotKey
;; -----------------------
;;
;; file: c:/Documents and Settings/username/My Documents/AutoHotkey.ahk
;;
;; #c = RightWindowsKey-c
;;
;; #c::
;; FileDelete, h:\tempfile
;; FileAppend, %clipboard%, h:\tempfile
;; return
;;
;; Note: h: in windows is mapped via samba a server to the unix homedir so
;; that ~/ on unix is the same file system as h: on windows
;; #v::
;; FileRead, Contents, h:\tempfile
;; Send %Contents%
;; Contents =
;; return
;; Shell - ZSH
;;
;; In .zshrc (M-i t) will insert $(< ~/tempfile). To expand immediately press C-x *
;;
;; bindkey -s "^[ic" ' > ~/tempfile'
;; bindkey -s "^[it" '\$(< ~/tempfile)'
;; override this in the machine or sytem specific file as needed
(defvar vj-tempfile-name "~/tempfile")
(defun my-insert-specific-file ()
"My insert ~/tempfile in buffer (VJO 1997)."
(interactive "")
(insert-file-contents vj-tempfile-name)
)
(defun my-copy-region-to-file (beg end)
"My copy region to a file called tempfile in my home-dir (VJO 1997)."
(interactive "r")
(if (file-exists-p vj-tempfile-name)
(rename-file vj-tempfile-name (concat vj-tempfile-name "_") t))
(write-region beg end vj-tempfile-name))
(defun my-open-tempfile ()
"Reopen ~/tempfile (VJO 2012)."
(interactive)
(dolist (buf (buffer-list))
(when (and (buffer-file-name buf)
(equal
(expand-file-name (buffer-file-name buf))
(expand-file-name vj-tempfile-name)))
(kill-buffer buf)
))
(find-file vj-tempfile-name))
(global-set-key [S-f6] 'my-copy-region-to-file)
(global-set-key [C-S-f6] 'my-insert-specific-file)
(global-set-key [C-f6] 'my-open-tempfile)
(provide 'vj-copy-paste)