Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. (ess-load-file (file-name-nondirectory (buffer-file-name)))
  2.  
  3. (defun my-copy-file ()
  4. (interactive)
  5. (cond ((equal "home.org" (file-name-nondirectory (buffer-file-name)))
  6. (write-region (point-min) (point-max)
  7. (concat "~/org/" (file-name-nondirectory (buffer-file-name)))))))
  8.  
  9. (add-hook 'before-save-hook #'my-copy-file)
  10.  
  11. ;; /plink:user@my.host.org:/the/remote/path/finename.cc
  12. (defun my-mirror-remote-file ()
  13. (interactive)
  14. ;; first search the at sign `@' in the buffer file name
  15. (let* ((file_name (buffer-file-name))
  16. (atpos (string-match "@" file_name)))
  17. ;; if there is an at sign in the file name, we assume it is a remote file
  18. (cond (atpos
  19. ;; we look for the second colon, which is after the host part
  20. ;; and we get the diretory and file name
  21. (let* ((hoston (substring file_name atpos))
  22. (colonpos (string-match ":" hoston)))
  23. ;; and we write the file locally (it will NOT create the dir though)
  24. (write-region (point-min) (point-max)
  25. (concat "~" (substring hoston (+ colonpos 1)))))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement