Lisp: create a macro to cycle through the created list on a document

Let's say I want to create a new document and quickly go through the list. If this is just for one β€œword," I think there should be a general way to do this.

For instance:

"blue orange red yellow black white" 

Does anyone know a way to cycle these elements around while creating:

 \begin{orange} 

... and I want to press a key to iterate over this list, replacing orange with the next item in the list (doing this procedure in the opposite direction would not be difficult)?

I tried a lot of different ideas with a macro (placing a list at the top of the document and executing a number of i-queries), but that doesn't shorten it.

I would like to put the list in an elisp file, although I do not know how to use this variable from elisp in, say, a LaTeX document (.tex).

+4
source share
2 answers

EDIT: I translated the macro into a function.

Here is how I did it. I created a file called "list.list" where my "lists" are saved. I saved LaTeX templates for Beamer. I inserted them like this:

 Antibes Bergen Berkeley Berlin ..... Antibes 

Note that you should always place the first record twice so that it can be closed.

Here is the code:

 (defun cycle-list-word () (interactive) (right-word) (backward-kill-word 1) (find-file "/emacs-24.1/list.list") (search-forward (substring-no-properties (car kill-ring)) nil t) (right-word) (backward-kill-word 1) (bury-buffer) (yank) ) 
+1
source

Well, it may be possible, but it depends on how much effort you are willing to put into writing eLisp code to make it work. This is not possible with any configuration option. I would consider an autocomplete extension, adding new sources to it, something like:

 (defvar tex-tag-ac-sources '((init . tex-tag-ac-init) (requires . 0) (candidates . tex-tag-ac-candidates) (document . tex-tag-ac-documentation) (match . tex-tag-completion-filter) (prefix . tex-tag-ac-prefix-matcher) (symbol . "s")) "The source generator for autocompletion needed for interaction with auto-complete") 

Where tex-tag-ac-candidates , tex-tag-ac-documentation , tex-tag-completion-filter and tex-tag-ac-prefix-matcher are auto-complete functions. That is, the init function is called once when the autofill process for the given prefix begins. It was called without argument. Candidates - this is the function that is responsible for showing the filtered list of candidates, it is called without arguments, you must filter the candidates in the filter function, it is called with the prefix collected so far and the list of candidates so far. Finally, the matcher function is called in the text of the file to find out if completion is required at the point. So, if it returns t , init is called, and then iterates through the selected filter candidates.

As long as this is a little connected ... you will most likely have a completion for everything you want. Obviously, if these functions in the source are defined by you, then if you want, you can dynamically read the completion arguments or generate them dynamically in some way.

And, you should add sources to autocomplete, for example:

 (auto-complete (list tex-tag-ac-sources)) 

if this is done for each call, or

 (setq ac-sources (list tex-tag-ac-sources <other sources>)) 

You can find more information here: http://cx4a.org/software/auto-complete/manual.html#Using_Source

+2
source

All Articles