Posts Tagged ‘Lisp’

Global Indentation

In order to get what people like to call smart indentation on Emacs, the easiest way is to add a couple of lines to the .emacs configuration to declare that every newline should be indented.

(define-key global-map (kbd "RET") 'newline-and-indent)
(setq-default indent-tabs-mode t)

The first line defines a global1 shortcut 2 for the command newline-and-indent assigned to the RET key (known Enter).

The second line turns-on (the t at the end means true) the TAB indentation… if it’s not turned-on by default!


1global means that it is valid for any emacs mode
2In emacs-lisp it is called define-key

Author: Oscar Castillo-Felisola

Created: 2013-11-07 Thu 15:08

Emacs 23.4.1 (Org mode 8.2.1)

Read Full Post »

Usually, when writing in LaTeX, one would like to comment and/or un-comment a section of the manuscript.

There is a package which allow you to comment a portion of the file. However, I found out that one can customize Emacs for inserting/remove a percentage sign at the beginning
of each line of a selected region.

Change the .emacs file

In order to do so, one should change the .emacs file.

  • Open the file .emacs with your favourite text editor (say emacs, gedit, nano… vi?)
  • Add the following lines,
    (defun uncomment-region (beg end)
      "Uncomment a region of text"
      (interactive "r")
      (comment-region beg end -1));
    (global-set-key "\C-c;"      'comment-region)
    (global-set-key "\C-c:"      'uncomment-region)
  • Save changes and close the editor
  • Start using the new feature

    Next time you open Emacs, you could select a region and use C-c ; for comment the region. Or if it is commented, use C-c : for un-comment it.



    Read Full Post »

    Some times, depending of the resolution of the monitor, the window of Emacs is bigger than it should. For controlling the size, I added a Lisp line to my .emacs file

    (setq default-frame-alist '((width . 80) (height . 33) (menu-bar-lines . 1)))

    which set the display to 80 columns and 33 rows.


    Read Full Post »

    After upgrade to Ubuntu 10.10, my emacs got a bug. Whenever I wanted to enable the flyspell-mode, minibuffer answer was “Enabling Flyspell mode gave an error”, no more information were given even with the debugger turned on.

    Some googling, web surfing, et cetera… and still nothing.

    Finally, right now (after almost 3 week, and quasi-given up), it occurs to me that and update of Emacs could solve the problem… How?

    THAT’S IT!!!!! I looked for an Emacs PPA source,

    $ sudo add-apt-repository ppa:ubuntu-elisp/ppa
    $ sudo apt-get update
    $ sudo apt-get dist-upgrade

    And problem solved.

    Read Full Post »