6

Just remembered it was auto-insert-mode. Make a new elisp file, run M-x auto-insert, and it prompts for summary, author, inserts the license and everything.


6

I'm using this yasnippet: # -*- mode: snippet -*- # name: ifndef # key: ifndef # -- #ifndef ${1:`(upcase (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`_HH_} #define $1 $0 #endif You can quickly customize it to do what you want. In case you're not using yasnippet yet Here's my personal config (you can take the parts that you ...


5

This works for me: (define-auto-insert '("/bin/.*[^/]\\'" . "Shell-Script") [(lambda () (sh-mode)) ("Default shell script: " "#!/bin/bash\n\n" > _)]) There are two issues here. auto-insert can call functions as a part of the action, but for some reason it has to be a lambda form. (I wonder why it checks for lambda instead of calling ...


4

The manual says the following. Subskeletons are inserted recursively, not once, but as often as the user enters something at the subskeletons interactor. Thus there must be a str in the subskeleton. They can also be used non-interactively, when prompt is a lisp-expression that returns successive list-elements. (Emphasis is mine, see section Skeleton ...


3

You just need to escape the " with a backslash \". You can also concatenate some of the strings. Only the final newline needs to be quoted: (define-skeleton tdd-clojure-skeleton "Define a skeleton " "function name: " "#+NAME:" str "-test" \n "#+BEGIN_SRC clojure" \n "(facts \"about \'" str "\'\"" \n " )" \n "#+END_SRC ...


3

While I can't tell you anything about skeletons, you can try the following: (define-key org-mode-map (kbd "$") (lambda () (interactive) (if (org-in-block-p '("SRC" "EXAMPLE")) (self-insert-command 1) (self-insert-command 2) (backward-char)))) The binding works only for org-mode and inserts $$ if the cursor is not in BEGIN_SRC ...


2

smartparens (and some other "auto pair" packages) allows you to do something similar: (sp-pair "#ifdef" "#endif") This won't easily get you that ending comment like a snippet engine can (I believe it's possible with smartparens, though), but it answers your title so I thought it was close enough to warrant an answer.


1

skeleton-read will read from the minibuffer, which is a separate buffer that's not using latex-mode, which is why your abbrev isn't working there. You could put your abbrev in global-abbrev-table so it's also available in the minibuffers, you could do: (define-skeleton myfunc "" "" (setq v1 (minibuffer-with-setup-hook (lambda () (setq ...


1

As phils said obtain the directory name (file-name-directory (or buffer-file-name "")) and then open a boilerplate template in that directory is maybe what you want rather than configure the template code in Emacs itself. I knocked this up and it seems to work. (defun insert-boilerplate () (let ((boiler-plate-file (expand-file-name ".boilerplate" (...


1

When constructing the contents of a particular buffer (or portion thereof), it is helpful to think about storing one or more locations (e.g., a buffer position) that may be needed later on in the function. Sometimes a location needs to be calculated or searched for. We could have inserted all of the text and then searched backwards for "My title", but that ...


1

If you are trying to move keys around, but only in emacs, then it is probably easier to use a translation keymap. (define-key key-translation-map "[" "{") (define-key key-translation-map "(" "[") As far as the binding to skeleton-pair-insert-maybe, I don't see this being setup to any key. You can use the code How can I find out in which keymap a key is ...


1

From the verilog-mode.el source, the verilog-sk-header-tmpl is used only in two places: Where the skeleton is defined Where the skeleton is used in a verilog-sk-header function So all you need to do is define your own skeleton using (define-skeleton my/verilog-sk-header-tmpl "Insert a comment block containing the module title, author, etc." ;; !!INSERT ...


Only top voted, non community-wiki answers of a minimum length are eligible