Yasnippet is a great emacs minor mode that lets you have lots of code snippets easily at hand. Also you can create your own snippets in a very easy way without needing to write them in emacs lisp. Basically, like textmate shortcuts for emacs.
I use html-helper-mode to edit all my html code, but yasnippet works with html-mode only out-of-the-box. To make it work with html-helper-mode, add ‘html-helper-mode-hook’ to yasnippet.el on line 121:
It should look like this: '(ruby-mode-hook actionscript-mode-hook ox-mode-hook python-mode-hook html-helper-mode-hook))
Then make a symlink to html-mode on the snippets folder. Assuming you are on yasnippets snippets/text-mode/ directory, type:
ln -s html-mode/ html-helper-mode
And now all html snippets will be available on html-helper-mode too.
Identi.ca is a free software microblogging service, similar to Twitter, based on the Status.net code base. I recently needed to update my status from Emacs, since its faster for me and easier. I’ve been using an an Emacs mode to update my Twitter account, but there was nothing to use for my Identi.ca account. And seeing there’s a Vim plugin, I thought someone, like me, needed an Emacs mode too.
Replace servername with your server (if connecting to Identica service, use identi.ca as server name), yourusername and yourpassword with your information.
You can also authenticate using OAuth, specially if you log in with an OpenID account which has no password. To use OAuth authentication (requires using oauth.el), add the following to your .emacs file:
(setq identica-auth-mode "oauth")
If you want to post from the minibufer without having identica buffer active, add the following global keybinding. Add this to send status updates
the buffer ‘*identica*’ will appear and you can see your friends timeline.
Press the “i” key to toggle icon mode to see user pictures.
To view your replies timeline
To view the public timeline
To view your friends timeline (the default timeline)
To view a user’s timeline
To view a group’s timeline
To view a tag’s timeline
To refresh the buffer’s timeline press “g”.
To post an update of your status, press
type your message in the minibuffer, and hit Enter. You will see ‘Success: Post’ in minibuffer.
To send a direct message to a user, press
On the minibuffer, you will be prompted for the username, then for the message.
To repeat (re-dent) a message, press
while the cursor is on the message’s line.
To favor a message, press the “F” key (shift f) while the cursor is on the message’s line.
Additionally, you while typing your message you can press <F4> key while the cursor is over a URL to shorten it using any of the following URL shortening services: Ur1.ca, TightURL, Goo.gl, TinyURL, To.ly and Is.gd. To expand an short url in your timeline, position your cursor over the short url and press ‘e’ key, it will be replaced with the expanded version in a few seconds.
Hope it can be of use for anyone using Emacs for almost everything, like I try to do, and would like to hear some feedback.
You can also help out if you’ve liked Emacs identica-mode and have some spare change. It would be great to support this project by making any kind of donation on the “tip jar” in appreciation of the hours invested on its development and improvement.
Recently I had to edit multiple files (239 in total) scattered in a bunch of directories and subdirectories. Here’s a quick and safe way to do it.
What I had to do was add the Google Analytics script snippet to a part of a website that was being maintained by a pair of <your favorite bad adjective here> developers.
So, first I thought of using sed or awk or something like that, but doing a quick search replace like that without checking if my match is correct in every instance in a bunch of files can lead to a big disaster.
But wait, I have Emacs! So, the first thing to do is find and list all the files you need to edit.
Open the parent directory
Use dired to open the parent directory where all the files and directories are. Open dired with:
and enter the path for the directory.
Find the files
Emacs will then prompt: “Run find (with args):”. So if you need to edit all HTML files, or in my case, PHP files, you type:
If you want all files regardless of type, enter
Basically you can type in any arguments you want if you know how to use the find command.
Mark the files you need to edit
A list of all found files will appear in a dired buffer. Now you need to mark the files you want to work with. Typically you’ll mark all files since you already filtered them. Press t to toggle marks and all files will get marked. Or if you want to hand pick them, move the cursor to the file line or name and press m.
Do the find and replace
Type: Press Q or M-x dired-do-query-replace-regexp to run the find and replace command. It will prompt you first for the text you want to find, then will prompt you with the text you want to replace it with.
Then Emacs will start the find and replace operation, and will prompt you on every find if you want to replace the text or skip it. To replace, type y, to skip to the next find type n. To replace all occurrences without asking, type !. To cancel the operation, type C-g.
Save the edited files
Now that you’ve made all these changes, you need to save the files. To avoid saving manually all files, you can open ibuffer
Which will list all you opened files (called buffers). Now, like in dired, you need to mark the buffers you want to work with. To mark all unsaved files, type * u and then type S (that’s shift+s, for the capital letter) to save them.
For those who have to code in PHP, there’s a nice feature in Emacs that makes your coding horror times less stressing and helps you avoid typos and similar dumb errors. For example in the image above, I missed the colon at the end of the line.
Emacs 22.1 comes with flymake mode, a nice tool that makes syntax checking while you type out the file by highlighting the lines with errors and displays the error messages.
You can enable flymake to check PHP syntax by adding the following code on your .emacs or whatever Emacs customizations file you use:
This speed of publishing is thanks to Emacs. I use tramp mode to edit and fix files remotely on the ACM servers via ssh. Tidy with html-mode to validate and fix all markup so that the files are XHTML 1.1 Strict. Dired mode to rename, move, copy files, and image mode to check if images are correct.
I wonder if I can edit images (like crop, resize, convert to jpeg, compress) in Emacs. I know you can edit videos, so images can’t be more difficult.