From 372df13155da3bf9ccce3fc01eb54cfc78661870 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Sun, 29 Jul 2018 19:05:26 +0200 Subject: [PATCH] Move functions from file-manip.el to the Org config --- configuration.org | 40 ++++++++++++++++++++++++++++++++++++++++ init.el | 1 - lisp/file-manip.el | 35 ----------------------------------- 3 files changed, 40 insertions(+), 36 deletions(-) delete mode 100644 lisp/file-manip.el diff --git a/configuration.org b/configuration.org index 40b5c78..faa8283 100644 --- a/configuration.org +++ b/configuration.org @@ -311,6 +311,46 @@ Esentially it visits the file again." (setq gpolonkai/last-killed-buffer-file-name nil)) (message "The buffer last killed didn’t 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 diff --git a/init.el b/init.el index 83a9af1..c2950cf 100644 --- a/init.el +++ b/init.el @@ -31,7 +31,6 @@ (load "zim") (load "text-manip") (load "frame-manip") -(load "file-manip") (load "window-manip") (load "xdg-paths") (load "utils") diff --git a/lisp/file-manip.el b/lisp/file-manip.el deleted file mode 100644 index c44272c..0000000 --- a/lisp/file-manip.el +++ /dev/null @@ -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