Emacs Lisp Blog Archive - Nov 2015

Posts Below
11/14/2015 - Emacs Lisp code: Insert a NoteCase-like Date/Time with F5 (Code Snippet)
11/14/2015 - Emacs Lisp code: Get Rid of 100-Item Limit on Lists in Helm (Code Snippet)
11/16/2015 - Emacs: How to have tabbing and indentation similar to a more typical text editor

    Hide/Show:


   ▲ Top  ▼ Bottom  △ TOC   ↓ Down
Emacs Lisp code: Insert a NoteCase-like Date/Time with F5
Saturday, November 14th, 2015
15:16:18 GMT


Code Snippet

The below Emacs Lisp code, which simply inserts a date/time like "2015-11-14 10:01:14" when you press F5, was a slight modification of code I found at this StackOverflow page:

How can I insert current date and time into a file using Emacs?


I used "defcustom" and "setq" instead of "defvar" alone because of tips from this page from ErgoEmacs.org:

Emacs Lisp "defvar" Doesn't Override


   ▲ Top  ▼ Bottom  △ TOC   ↓ Down


   ▲ Top  ▼ Bottom  △ TOC   ↓ Down   Up ↑
Emacs Lisp code: Get Rid of 100-Item Limit on Lists in Helm
Saturday, November 14th, 2015
15:44:27 GMT


Code Snippet

I never before had to fiddle so much with an editor to make it comfortable to use - but, it seems to be paying off, since the idea of sticking with Emacs is starting to seem not only plausible, but appealing. Perhaps I'll be able to return to my usual projects sometime in the next few weeks.

I've been downloading lots of different Emacs add-ons - many of them listed in this section of my GitHub account.


The add-on Helm makes it much easier to access and list various useful things, such as Emacs' fortunately copious documentation of things like Emacs Lisp functions and variables.

In my ".emacs" settings file, I have this line after the stuff which starts Helm:

That line slows things down a bit, but at least it gets rid of the 100-item limit on the length of lists in Helm.

   ▲ Top  ▼ Bottom  △ TOC   ↓ Down   Up ↑


   ▲ Top  ▼ Bottom  △ TOC   Up ↑
Emacs: How to have tabbing and indentation similar to a more typical text editor
Monday, November 16th, 2015
05:34:36 GMT


The Emacs editor has a bunch of default behaviors that were driving me crazy:

(Plus other, less insanity-inducing problems - but those aren't solved in this post.)

And also the automatic indentation in php-mode.


Finally, I figured out how to fix all of that, and make Emacs' tabbing and auto-indenting be more like a typical text editor.

But, I'm pretty new to Emacs, so, there might be side effects or other problems with the below solution I'm not yet aware of. Comments are welcome!

Thanks to everyone on the web who posted useful info and/or code which enabled me to cobble together my current favorite solution.


The only Emacs add-on the below code requires is regtab.el, which makes it possible to indent either one line or entire highlighted regions by pressing tab, and un-indent them by pressing shift-tab.

I put the below code in my ".emacs" settings file. I'm using Emacs 24.5.1.


I had some trouble figuring out how to make php-mode stop doing automatic indent. So, finally, I just resorted to the brute force method of editing php-mode.el's source code.

In php-mode.el, I changed every instance of indent-tabs-mode nil to indent-tabs-mode t, and every instance of tab-width 4 to tab-width 7. (But you can use whatever tab-width number you like).

I don't yet know of a less invasive way to fix it than that. But, that worked.


To stop regtab.el from displaying the text "regtab" in your modeline, you can comment out these lines in regtab.el:

(define-minor-mode regtab-mode "Regular Tabs Minor Mode"
  :lighter " regtab" :keymap regtab-mode-map)

And use this line instead, with "lighter" set to "nil". (It's included in the box of code above, so you can just uncomment it.)


Click this link to display the blog comment thread hosted at the Eryss.Com Forum:

   ▲ Top  ▼ Bottom  △ TOC   Up ↑


    Hide/Show: