(defunxah-update-article-timestamp ()
"Update article's timestamp.
Add today's date to the form
<p class=\"author_0\">Xah Lee, <time>2005-01-17</time>, <time>2011-07-25</time></p>
of current file."
(interactive)
(let (p1 p2)
(save-excursion
(goto-char 1)
(when (search-forward "<p class=\"author_0\">Xah Lee" nil)
(beginning-of-line)
(setq p1 (point) )
(end-of-line)
(setq p2 (point) )
(search-backward "</p>")
(insert (format ", <time>%s</time>" (format-time-string "%Y-%m-%d"))
) ) ) ))
press a button, then current page's date stamp is updated. This command saves me about 30 keystrokes and error-prone manual process.
you might modify this to update your blog, code, org-mode file, for similar purpose.
the point of this post is not about a trick to auto-update timestamp, but rather, the usefulness of little emacs lisp code, that can update anything uniquely identifiable in current file (or even another file.)
recently, rewrote several elisp code for syntax color source code in HTML. This is real convenient if you write blogs and often have computer language source code. For example, if you have:
<preclass="python">
…
print 5
…
</pre>
Press a button, then the code is syntax colored with span tags. If it's already syntax colored, then all span tags are removed. (it's a toggle).
Press another button, the source code is moved into a temp file xx-temp.py with split window.
This is similar to how you can execute code in org-mode.
I've been writing emacs tutorial for about 6 years. I started using emacs daily in 1998. Then, around 2005 i joined emacs irc channel, and learned a whole lots of things i thought i knew. I started to write notes to myself, then some tips are really useful that i felt others would benefit. One of the first such tutorial is Emacs & Unicode Tips. In the past 3 years or so, i've been working on the tutorial about 3 hours a day. When i get a praise, it brightens my day, especially from experienced emacs users.
I got this hearty one today.
Thank YOU for your fantastic resource. I've been an emacs user for 28 years, and I've learned countless things from your tutorials.
If you like my tutorial, read it, subscribe, tell friends, or Buy it please. That'd give me much incentive to make it better. Thank you.
I just sent out download link to my emacs tutorial. If you bought it before but didn't receive the email, please email me xah@xahlee.org and say “emacs tutorial update”. I'll email it to you and put you on the mailing list. Thank you.
Also, i just got one person's payment but the email to him bounced. Be sure your email is correct, else i have no way to contact you. Email me please.
Question to Readers: {Perl, Python, Ruby}, Together on One Page, or Separate?
I have a Perl + Python tutorial. There, each page, has both languages for comparative study.
My question is, should i also put my new Ruby Tutorial there for comparative study? Or, should Ruby by itself?
I can actually also put {Emacs Lisp, PHP} there for comparative study too. But then each page will be long. Alternatively, if each language is on separate page, with inter-links, then people could page between any two languages.
Which way do you prefer?
Again, the ErgoEmacs keybinding package has been updated a lot. By Matthew L Fidler (https://github.com/mlf176f2). Most of the codes are by Matthew and David Capello.
IMPORTANT: Note: in the dev version, the isearch is moved from 【Alt+;】 to 【Alt+y】. Cancel command is moved from 【Alt+n】 to 【Esc】. (here, using QWERTY notation)
moving emacs dot files into 〔~/.emacs.d/〕 started in emacs 23, but it didn't catch all. Emacs 24 moved more, but still some left. As of now, i still see these (some are created 3rd party elisp packages):
Is there a way in emacs to sort with a primary field and then a secondary field. I remember Linux command sort having one such option.
You call sort-fields or sort-numeric-fields multiple times. But you could call unix sort with text selection as input and replace selection. Call shell-command-on-region 【Ctrl+uAlt+|】.
Is there a better way to sort by multiple fields in one shot?
There, anyone can post and share tips, ask questions. Hope to see you there.
copy rectangle to kill-ring
Here's a command from from YoungFrog,
I have a suggestion: to copy rectangles to the clipboard you could use extract-rectangle and insert-rectangle to avoid using registers. Here is an example with the kill ring instead of the clipboard:
(defunyoungfrog/copy-rectangle-to-kill-ring (start end)
"Saves a rectangle to the normal kill ring. Not suitable for yank-rectangle."
(interactive "r")
(let ((lines (extract-rectangle start end)))
(with-temp-buffer
(while lines ;; insert-rectangle, but without the unneeded stuff
;; (most importantly no push-mark)
(insert-for-yank (car lines))
(insert "\n")
(setq lines (cdr lines)))
(kill-ring-save (point-min) (point-max)))))
I wanted to thank Matthew L Fidler
(https://github.com/mlf176f2)
again. He's been hacking on ErgoEmacs keybinding package. Basically a rewrite. Massive work. Still going. I can see a lot emacs lisp expertise going on there.
Also, before that, David Capello did the heavy lifting. Made the package from simple global set key into a full-featured minor mode, and started supporting various layout and international layouts.
Ask Emacs Tuesday. Today i like to ask you all this question. If you are a perl/python/ruby developer, what emacs packages, configuration, do you use? Please do post your .emacs on github (or other) too. After today, i'll do a summery to share with you all.
I'll start with myself. Perl i had many years of day job experience. I use cperl-mode (part of emacs now). I have a comparison of perl and cperl here:
Emacs: perl-mode vs cperl-mode
Python i do as a hobby for many years, and recently been learning ruby.
Overall, i honestly can't say i use many packages/setup that are specific to these languages.
The bulk of convenience lies in generic emacs features.
They are, all the completion packages i mentioned recently 〔☛ Emacs: Name Completion Features & Packages〕. Then, heavy use of emacs features and setup, such as dired, bookmark, many find/replace features, dired-do-query-replace-regexp, keyboard macro, “shell”, “shell-command”, many other …. Hard to really pick out specific ones.
(almost all of these generic features you can learn more at Xah Emacs Tutorial )
some people i know have one specific setup/environment for one of perl/python/ruby. So what are they? Also, if you know a expert who code one of these languages with emacs, please do post their git .emacs URL (or other repository). For those emacs-prelude and other pre-packaged emacs users, do tell us what setup there you find really helpful.
especially interesting are those setup with ipython or other some type of dynamic integration. Also, some provide doc integration. Which are they? (i used to have perl doc in info format, but not now. Where can i find perl/ruby/python doc in info format?) I've also heard keys that lets you directly read the inline doc of function/method of perl/python/ruby, similar to emac lisp's describe-function. Anyone have such setup? So, please do go thru your day work tell us what packages/features you can't live without for doing dev with that lang.
I'll do a summery afterwards, and hopefully it'll be heplful to many. thanks.
New Dev Version of ErgoEmacs Keybinding Package
Matthew L Fidler did a huge overhaul of the ErgoEmacs keybinding package. LOTS new features. If you are adventurous, you might want to take a look and try the latest. Thank you Matt!
Here's a quick summery of the changes/new features:
Layouts code now uses visual format (kinda like ASCII art), so you can easily create different layouts.
Layouts can be customize using emacs's customize feature.
Includes SVG (scalable image) files for the layouts.
Generates AutoHotkey code (for creating system-wide ErgoEmacs layout on Microsoft Windows)
Generates Mac OS X DefaultKeyBinding.dict code (for creating OS-wide ErgoEmacs layout)
You can read detail in the included _HISTORY.txt file.
Stable version (v5.3.7) that's 2 year old is in a zip file here: ErgoEmacs Keybinding, in case you want to compare the differences.
Note: the version on MELPA is also kinda old. It's slightly newer than 5.3.7, but is also outdated. (last i checked, it's still based on svn source, which we changed to git a while ago. I haven't had time to contribute to MELPA. Thanks to the person who puts it on MELPA.)
I'm currently looking for work, so won't be able to contribue much this month.
Yesterday, i spent a hour doing a regex in elisp. Failed. Frustrated. Switched to python, done the job in 20 seconds.
In elisp, you have these char classes: {[:graph:], [:nonascii:], [:print:]}.
(☛ (info "(elisp) Char Classes"))
The documentation is not detailed. I don't think anyone uses it. And, it doesn't seem to work. (not to mention the toothpick syndrome when the regex is in lisp code.)
For example, elisp manual says:
`[:print:]'
This matches printing characters--everything except ASCII control
characters and the delete character.
Moral: emacs regex sucks donkey ass.
Addendum: LOL. Actually, i just discovered that i was using <head>… in elisp, but it should be <header>…. So, NEVERMIND!