[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ next ]


Some Mini-Howtos of Interest
Chapter 4 - Emacs text editor


4.1 Emacs macros

Updated on February 7th, 2016.

To define several emacs macros simultaneously and save them, the macros should be named. To give a macro a name define the macro and then execute M-x (name-last-kbd-macro) and give the macro a name[8].

The defined macro can be executed with the key combination C-x e unless a new macro is defined. When the last macro defined is not the one that should be executed, it should be recalled by its name as M-x macro_name.

If you consider the macro worth to be saved for future sessions you can open a file and save the macro in this file with the command M-x insert-kbd-macro RET macroname RET. You can load the file later with load-file.

The macro can also be added to the emacs startup file. In order to do so, open the .emacs file or the file where you keep emacs macros and execute M-x (insert-kbd-macro) giving the name of the macro to be saved.


4.1.1 References

  1. http://www.emacs.uniyar.ac.ru/doc/em24h/emacs112.htm

  1. Emacs Manual


4.2 Changing the default system's text editor to Emacs

In order to change the default system's text editor to emacs or other alternative as vi in a Debian system the root user can update the system's default

     $ sudo update-alternatives --config editor 
     [sudo] password for curro: 
     
     There are 4 alternatives which provide `editor'.
     
       Selection    Alternative
     -----------------------------------------------
               1    /bin/ed
     *+        2    /bin/nano
               3    /usr/bin/vim.tiny
               4    /usr/bin/emacs22
     
     Press enter to keep the default[*], or type selection number: 4
     Using '/usr/bin/emacs22' to provide 'editor'.
     $

Some programs use the environment variables $EDITOR or $VISUAL to decide which editor to use. For the sake of consistency on Debian systems, these variables should be set to /usr/bin/editor.


4.3 Removing empty lines in Emacs

Created on May 21st, 2015.

In order to remove all blank lines in a text file (or a selected text file region) you can use the command M-x flush-lines that removes all lines that matches a regexp condition as follows

     M-x flush-lines RET ^$ RET

In case you want to remove lines containing only spaces the command is

     M-x flush-lines RET ^\s-*$ RET

4.3.1 References

  1. Mastering Emacs


4.4 Reading init file .emacs

Created on December 7th, 2017.

If you perform changes in the emacs init file .emacs and you want to reload the definitions in an already open editor instance there are several ways to proceed:

  1. Open emacs and then load-file (M-x load-file, then press return twice to accept the default filename, which is the current file being edited).

  1. move the point to the end of any sexp and press C-xC-e to execute just that sexp. Usually it's not necessary to reload the whole file if you're just changing a line or two.

  1. Open .emacs and execute M-x eval-buffer. It immediately evaluates all code in the buffer.


4.4.1 References

  1. Answer from Stackoverflow


4.5 Commenting a region of a code in Emacs

Created on February 23rd, 2016.

In order to remove comment several lines of a source code, in LaTeX, Python, Fortran, etc. select the region to comment and press M-;. To uncomment a region type C-u C-;.


4.5.1 References

  1. Emacs manual


4.6 Emacs org-mode

Added on December 6th, 2017.

We include in this section information about different aspects of the Emacs text editor and its org-mode.

  1. Adding a title, a subtitle, and an author name to an org-mode file is done in the preamble as in the following example

         #+TITLE: Notes on the Quartic Potential
         #+SUBTITLE: Quantum Cusp and Isomerization in 1D
         #+AUTHOR Curro PĂ©rez-Bernal
         #
         #+STARTUP: latexpreview
    

    The #+STARTUP: latexpreview command in the preamble produce a preview image of the LaTeX fragments in the text at point and overlay them over the source code. To activate tttttttttttttttttttttttt

    Adding references from a bibtex. Include a line

         	      #+BIBLIOGRAPHY: refs plain
    

    and call org-reftex-citation each time you need to include a reference.

  1. Shortcuts of interest:

    1. TAB (Shift-TAB) :: Fold-unfold parts. With Shift affects the whole file.

    1. Alt-up/down :: move a headline up or down


4.6.1 References

  1. http://www.emacs.uniyar.ac.ru/doc/em24h/emacs112.htm

  1. Emacs Manual


4.7 Including comments and footnotes in the References section

Created on January 2nd, 2019.

The inclusion of footnotes and remarks in the reference list is provided by the package notes2bib. To load the package, include a line \usepackage{notes2bib} in the text head. Then any footnote content or relevant note can be deal with the command \bibnote as follows

     There are two variables, $a$ and $b$\bibnote[]{The $b$ variable is
     related to the quantum number $c$ as $b = 2c$.} and two control parameters: A and B.

Note that if you do not include the empty squared braces option in bibnote a label to your comment will be added in addition to the reference keynote.


4.7.1 References

  1. notes2bib documentation


[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ next ]


Some Mini-Howtos of Interest

Curro Perez-Bernal mailto:francisco.perez@dfaie.uhu.es