From 21b333bb2ced1184b2e6fee8eefce4d0c8796f62 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 8 Mar 2014 11:01:29 +0100 Subject: [PATCH] Emacs: insert-file-name function --- .emacs.d/abbrev_defs | 53 +++++++++++++++++++++++++++++++++++++------ .emacs.d/functions.el | 21 +++++++++++++++++ 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/.emacs.d/abbrev_defs b/.emacs.d/abbrev_defs index 87b31537..557f0fb6 100644 --- a/.emacs.d/abbrev_defs +++ b/.emacs.d/abbrev_defs @@ -5,21 +5,39 @@ (define-abbrev-table 'awk-mode-abbrev-table '()) -(define-abbrev-table 'c++-mode-abbrev-table - '( - )) +(define-abbrev-table 'bibtex-mode-abbrev-table '()) + +(define-abbrev-table 'c++-mode-abbrev-table '()) (define-abbrev-table 'c-mode-abbrev-table '( ("printf" "" cc-printf 0) )) +(define-abbrev-table 'calendar-mode-abbrev-table '()) + (define-abbrev-table 'comint-mode-abbrev-table '()) (define-abbrev-table 'completion-list-mode-abbrev-table '()) +(define-abbrev-table 'conf-colon-mode-abbrev-table '()) + +(define-abbrev-table 'conf-javaprop-mode-abbrev-table '()) + +(define-abbrev-table 'conf-ppd-mode-abbrev-table '()) + +(define-abbrev-table 'conf-space-mode-abbrev-table '()) + +(define-abbrev-table 'conf-unix-mode-abbrev-table '()) + +(define-abbrev-table 'conf-windows-mode-abbrev-table '()) + +(define-abbrev-table 'conf-xdefaults-mode-abbrev-table '()) + (define-abbrev-table 'docTeX-mode-abbrev-table '()) +(define-abbrev-table 'doctex-mode-abbrev-table '()) + (define-abbrev-table 'emacs-lisp-byte-code-mode-abbrev-table '()) (define-abbrev-table 'emacs-lisp-mode-abbrev-table '()) @@ -32,10 +50,14 @@ (define-abbrev-table 'help-mode-abbrev-table '()) +(define-abbrev-table 'html-mode-abbrev-table '()) + (define-abbrev-table 'idl-mode-abbrev-table '()) (define-abbrev-table 'java-mode-abbrev-table '()) +(define-abbrev-table 'latex-mode-abbrev-table '()) + (define-abbrev-table 'lisp-mode-abbrev-table '()) (define-abbrev-table 'lua-mode-abbrev-table '()) @@ -48,10 +70,16 @@ (define-abbrev-table 'occur-mode-abbrev-table '()) +(define-abbrev-table 'org-mode-abbrev-table '()) + (define-abbrev-table 'outline-mode-abbrev-table '()) +(define-abbrev-table 'perl-mode-abbrev-table '()) + (define-abbrev-table 'pike-mode-abbrev-table '()) +(define-abbrev-table 'plain-tex-mode-abbrev-table '()) + (define-abbrev-table 'po-mode-abbrev-table '()) (define-abbrev-table 'process-menu-mode-abbrev-table '()) @@ -60,10 +88,17 @@ (define-abbrev-table 'select-tags-table-mode-abbrev-table '()) +(define-abbrev-table 'sgml-mode-abbrev-table '()) + (define-abbrev-table 'sh-mode-abbrev-table '( - ("null" "" sh-redirect-to-null 0) - )) + ("/null" "" sh-redirect-to-null 0) + ("null" "" sh-redirect-to-null 2) + )) + +(define-abbrev-table 'shell-mode-abbrev-table '()) + +(define-abbrev-table 'slitex-mode-abbrev-table '()) (define-abbrev-table 'snippet-mode-abbrev-table '()) @@ -71,6 +106,10 @@ (define-abbrev-table 'tabulated-list-mode-abbrev-table '()) +(define-abbrev-table 'tex-mode-abbrev-table '()) + +(define-abbrev-table 'tex-shell-abbrev-table '()) + (define-abbrev-table 'text-mode-abbrev-table '( ("ac" "avec" nil 0) @@ -87,7 +126,7 @@ ("atm" "at the moment" nil 1) ("autom" "automatique" nil 2) ("automt" "automatiquement" nil 2) - ("bcp" "beaucoup" nil 2) + ("bcp" "beaucoup" nil 3) ("biblio" "bibliothèque" nil 1) ("biblios" "bibliothèques" nil 1) ("btw" "by the way" nil 1) @@ -102,7 +141,7 @@ ("cmt" "comment" nil 1) ("coeur" "cœur" nil 1) ("coeurs" "cœurs" nil 1) - ("config" "configuration" nil 1) + ("config" "configuration" nil 2) ("configs" "configurations" nil 1) ("cpd" "cependant" nil 2) ("cvg" "converge" nil 1) diff --git a/.emacs.d/functions.el b/.emacs.d/functions.el index 194bc0d8..938922cb 100644 --- a/.emacs.d/functions.el +++ b/.emacs.d/functions.el @@ -152,6 +152,27 @@ current directory, suitable for creation" (and looping (not (equal current-dir "/"))))) (if (equal current-dir "/") nil (expand-file-name makefile current-dir)))) +(defun insert-file-name (filename &optional args) + "Insert name of file FILENAME into buffer after point. +Prefixed with \\[universal-argument], expand the file name to its +fully canocalized path. See `expand-file-name'. + +Prefixed with \\[negative-argument], use relative path to file +name from current directory, `default-directory'. See +`file-relative-name'. + +The default with no prefix is to insert the file name exactly as +it appears in the minibuffer prompt." + ;; Based on insert-file in Emacs -- ashawley 20080926 + (interactive "*fInsert file name: \nP") + (cond ((eq '- args) + (insert (file-relative-name filename))) + ((not (null args)) + (insert (expand-file-name filename))) + (t + (insert filename)))) +(define-key my-keys-minor-mode-map "\C-x\M-f" 'insert-file-name) + (defun kill-all-buffers () "Kill all buffers, leaving *scratch* only." (interactive)