Move functions from file-manip.el to the Org config

This commit is contained in:
Gergely Polonkai 2018-07-29 19:05:26 +02:00
parent d52a110acb
commit 372df13155
3 changed files with 40 additions and 36 deletions

View File

@ -311,6 +311,46 @@ Esentially it visits the file again."
(setq gpolonkai/last-killed-buffer-file-name nil))
(message "The buffer last killed didnt visit a file.")))
#+END_SRC
*** Open this file as another user
#+BEGIN_SRC emacs-lisp
(defun open-this-file-as-other-user (user)
"Edit current file as USER, using `tramp' and `sudo'.
If the current buffer is not visiting a file, prompt for a file
name."
(interactive "sEdit as user (default: root): ")
(when (string= "" user)
(setq user "root"))
(let* ((filename (or buffer-file-name
(read-file-name (format "Find file (as %s): "
user))))
(tramp-path (concat (format "/sudo:%s@localhost:" user) filename)))
(if buffer-file-name
(find-alternate-file tramp-path)
(find-file tramp-path))))
#+END_SRC
*** Open my own ~init.el~
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/visit-init-file ()
"Open the init file."
(interactive)
(find-file-other-window user-init-file))
#+END_SRC
*** Open my Org-mode index file
#+BEGIN_SRC emacs-lisp
(defun gpolonkai/visit-org-index ()
"Visit the root of Org-mode notes."
(interactive)
(find-file-other-window (concat (file-name-as-directory org-directory)
"index.org")))
#+END_SRC
** ~c-mode~ related
*** Copy the prototype of the current function

View File

@ -31,7 +31,6 @@
(load "zim")
(load "text-manip")
(load "frame-manip")
(load "file-manip")
(load "window-manip")
(load "xdg-paths")
(load "utils")

View File

@ -1,35 +0,0 @@
;;; file-manip --- Summary
;;; Commentary:
;;; Code:
(defun open-this-file-as-other-user (user)
"Edit current file as USER, using `tramp' and `sudo'.
If the current buffer is not visiting a file, prompt for a file
name."
(interactive "sEdit as user (default: root): ")
(when (string= "" user)
(setq user "root"))
(let* ((filename (or buffer-file-name
(read-file-name (format "Find file (as %s): "
user))))
(tramp-path (concat (format "/sudo:%s@localhost:" user) filename)))
(if buffer-file-name
(find-alternate-file tramp-path)
(find-file tramp-path))))
(defun gpolonkai/visit-init-file ()
"Open the init file."
(interactive)
(find-file-other-window user-init-file))
(defun gpolonkai/visit-org-index ()
"Visit the root of Org-mode notes."
(interactive)
(find-file-other-window (concat (file-name-as-directory org-directory)
"index.org")))
(provide 'file-manip)
;;; file-manip.el ends here