tag:blogger.com,1999:blog-23042512158267469682024-03-13T03:06:01.595-07:00Life Is Too Short For Bad CodeRandom musings about programming, software, technical interviews, and of course Emacs - a tip every week for new and experienced users.ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.comBlogger57125tag:blogger.com,1999:blog-2304251215826746968.post-90944579467092022812018-08-08T07:56:00.003-07:002018-08-08T07:56:22.084-07:00I'm so out of itI didn't even realize that Emacs 26.1 was released 3 months ago!ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com4tag:blogger.com,1999:blog-2304251215826746968.post-14984128058272854302010-10-23T13:36:00.000-07:002010-10-24T20:12:45.196-07:00Emacs Tip #38: Automatically diff binary files using hexl-modeI saw a question on Stack Overflow which referred to a non-free (as in beer) file comparison application. My first thought was, "people pay for this?" Sure enough, there are quite a few non-free file comparison tools. Which leads to the question, what do they offer that I'm not getting in Emacs (using ediff). From the table on Wikipedia, it appears not too much. I updated a couple of fields ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com5tag:blogger.com,1999:blog-2304251215826746968.post-76790134476388791192010-10-10T04:13:00.000-07:002010-10-10T11:25:16.197-07:00Emacs Tip #37: fic-mode.elI saw this question on Stack Overflow asking to highlight FIXME (and similar strings) in your code, but only in comments and strings.The current fixme-mode.el found on the Emacs Wiki is kind of clunky (it's really a major mode) and awkward to read. So I took the challenge to write a new minor-mode which answers the question.I give you fic-mode.el. It's named fic as an acronym for Fixme In ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com9tag:blogger.com,1999:blog-2304251215826746968.post-75351543416654074972010-06-22T13:14:00.000-07:002010-06-22T13:22:20.865-07:00vc-diff tweakFor a while I've noticed that 'vc-diff (C-x v =) would pop up a buffer when there were no differences, and that buffer would just say there weren't any differences. It finally got on my nerves, so I wrote this code which works around that issue.I don't totally understand the vc code, but parts are set up to run asynchronously, and that is what was tripping up 'vc-diff in my case. The diff wouldahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com4tag:blogger.com,1999:blog-2304251215826746968.post-70841518420041423912010-04-28T12:24:00.001-07:002010-05-01T15:34:39.944-07:00Emacs Tip #36: Abort the minibuffer when using the mouseA friend of mine loves using Emacs, but is always complaining about something. This time it's Emacs' behavior to keep the minibuffer active when you use the mouse to select another window. For example, you start doing a C-x C-f, click elsewhere, and do the C-x C-f again. Emacs will beep and tell you Command attempted to use minibuffer while in minibuffer.After swallowing my, "well don't use ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com15tag:blogger.com,1999:blog-2304251215826746968.post-77569852634815550622010-02-20T00:37:00.000-08:002010-02-20T00:54:49.278-08:00Emacs Tip #35: framemoveEver wanted to easily navigate between frames? Perhaps using arrow keys? Surprisingly, this didn't exist before (AFAIK).I wrote the package framemove to have the same usage as Emacs' built in windmove package. And, even better, it can integrate with windmove so that when you run out of windows to move between, you'll jump to the next frame in that direction.To install framemove on its own: ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com10tag:blogger.com,1999:blog-2304251215826746968.post-79700846697340156472010-02-11T17:19:00.000-08:002010-02-11T17:26:32.107-08:00Emacs Tip #34: line-beginning-position, line-end-positionSuch a simple thing - finding the position of the beginning or end of the current line. I've been completely oblivious to the existence of the functions line-beginning-position and line-end-position.They return the position of the beginning or end of the current line.They both accept an optional argument, which has the samemeaning as the argument to beginning-of-line or end-of-line.They were ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com2tag:blogger.com,1999:blog-2304251215826746968.post-29758717886710720102009-12-23T12:56:00.000-08:002009-12-23T13:31:13.408-08:00Emacs Paper from 1981It's been a while since I read RMS's paper on Emacs. Back in 1981, I still had another 2 years before I even saw my first computer. Reading the paper gives some insight into some of the issues they were trying to solve (real time display, extensibility, portability).The first thing that came to mind when I first read this paper was that (to an outsider at least) Emacs really hasn't changed ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com2tag:blogger.com,1999:blog-2304251215826746968.post-23835696308237473772009-09-30T20:57:00.000-07:002009-09-30T21:21:17.657-07:00Emacs Tip #33: pareditI recently found paredit. It is a mode which allows you to edit s-expressions (sexps) in a structured way.Essentially it forces you to maintain balanced parentheses by always inserting/deleting matched pairs. It is very easy to modify the current sexp to: enclose (wrap) the next element, to merge it up one level (aka splice, i.e. remove a set of parentheses), to split the current sexp, etc.It ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com5tag:blogger.com,1999:blog-2304251215826746968.post-17681428827182684692009-09-30T10:43:00.000-07:002009-09-30T11:29:43.184-07:00Somewhat meta: blogs on redditRecently, doing a vanity search, I saw a link to this blog from reddit. I'm not a reddit user, but found it interesting that some of my posts had made it on there (as you can see here: trey-jackson.blogspot.com on reddit.com).What I find curious about reddit as it applies to blogs is that it ends up taking the conversation away from the blog. This works well for reddit users, but ends up ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com2tag:blogger.com,1999:blog-2304251215826746968.post-66345420002443644282009-08-04T15:06:00.000-07:002009-08-04T15:13:39.974-07:00Emacs Tip #32: completion-ignore-case and Emacs 23Everyone is all a-buzz over the new release of Emacs. I've started using it, and I do like the font support.There was one surprise. I had the old setting(setq completion-ignore-case t)because I hate typing capital letters when I can avoid it. Enter Emacs 23.1, and I now have to type capital letters for buffer names and file names (which is 90% of what I use minibuffer completion for). It ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com1tag:blogger.com,1999:blog-2304251215826746968.post-87430074962623699032009-06-24T10:25:00.001-07:002009-09-30T10:42:04.284-07:00Emacs Tip #31: kill-other-buffers-of-this-file-nameA friend mentioned he wanted a way to get rid of all the other buffers visiting files that of the same file name. I instantly realized this was something I'd wanted for a long time without knowing it.My usage is that I'm often viewing different versions of the same file, usually in different sandboxes. And, I might also have older versions checked out, whose file names are the same, but end ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com2tag:blogger.com,1999:blog-2304251215826746968.post-48976283260987075372009-06-19T23:03:00.000-07:002009-06-19T23:28:00.596-07:00Searching GNU From FirefoxWhen writing up answers for Emacs related questions on stackoverflow.com, I like to include links to the info pages. I got tired of having to go to the gnu site and then do a google site-specific search. I tried looking for a Firefox search plugin that already did that (or something similar), but to no avail.However, it's pretty easy to write the search plugin yourself. The main page for ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com3tag:blogger.com,1999:blog-2304251215826746968.post-30437728874755379402009-06-12T13:53:00.000-07:002009-06-12T15:01:52.322-07:00Emacs Tip #30: igrepFinding text in files is an everyday (every hour) occurrence for most programmers. And in Unix-land, people generally use grep to do the searching.Of course Emacs has an interface to grep, which now (as of Emacs 22) even has interfaces for using both find and grep together to search through directory structures (grep-find, rgrep).But, before those existed, someone wrote a nice package igrep.el, ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com1tag:blogger.com,1999:blog-2304251215826746968.post-67102555901617333272009-05-19T11:12:00.000-07:002009-05-19T11:55:36.460-07:00Emacs Tip #29: customizing hippe-expandI read A Curious Progammer's post on customizing dabbrev - specifically to skip certain regular expressions at the front of words.I remember customizing it for Tcl to avoid looking at the $ used to dereference variables. But, I no longer use dabbrev, I use the slightly more general hippie-expand. However, hippie-expand doesn't use the dabbrev settings.So, the question is, can you get ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com1tag:blogger.com,1999:blog-2304251215826746968.post-68568185367171275152009-05-15T12:09:00.000-07:002009-05-15T12:51:16.552-07:00Stupid VNC TrickAt my office I have a dual monitor setup, and at home I have two monitors as well, so most of my VNC sessions are wide (3280 pixels).Which presents a problem on the occasions I decide to work from a coffee shop or some other place where I only have my laptop's screen. How do you effectively interact with a VNC session where the session is twice the size of the physical screen?Clearly scrolling ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com1tag:blogger.com,1999:blog-2304251215826746968.post-75844785252685625832009-04-27T14:46:00.000-07:002009-04-27T14:49:51.049-07:00dot-emacs trickery (emacs-fu)It's been a while, and to be honest, emacs-fu has been doing such a great job putting up useful snippets of Emacs information...He just put up a question asking for folk's favorite dot-emacs tricks. I added my two cents with:(defun tj-find-file-check-make-large-file-read-only-hook () "If a file is over a given size, make the buffer read only." (when (> (buffer-size) (* 1024 1024)) (setq ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com0tag:blogger.com,1999:blog-2304251215826746968.post-44220930667032969362009-03-27T12:18:00.000-07:002009-09-30T11:28:44.425-07:00Don't Like It? Code it Yourself!Jeff Atwood writes on a topic that's interested me for quite a while:Coding Horror: Don't Like It? Code it Yourself!To me, at least, sponsorship seems like a constructive way for people who are unable or unwilling to write code to affect the direction of a project. For example, I've sponsored several bugfixes in a key .NET open source library that we use for Stack Overflow. These are bugfixes ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com2tag:blogger.com,1999:blog-2304251215826746968.post-6243627212391751232009-03-03T12:04:00.000-08:002009-03-03T12:12:06.560-08:00More AdviceWay back when I wrote a tip about Emacs Lisp's advice.How I wish other languages had this capability. A couple of questions came up recently on stackoverflow.com that were (imo) best answered using advice. So, if you're struggling to see when to use advice, I think they're pretty good examples."Diff, save or kill" when killing buffers in emacsCan I change emacs find-file history?ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com0tag:blogger.com,1999:blog-2304251215826746968.post-56119894409852925522009-02-17T15:02:00.000-08:002009-02-17T15:10:10.001-08:00Dynamic Modal Bindings (auto prefixing)A guy posted an interesting question on stackoverflow: Most emacs modes include some sort of prefix to activate their features. For example, when using GUD "next" is "C-c C-n". Of these modes, many provide special buffers where one can use a single key to activate some functionality (just 'n' or 'p' to read next/previous mail in GNUS for example). Not all modes provide such a ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com0tag:blogger.com,1999:blog-2304251215826746968.post-15882863254824356412009-01-13T13:44:00.001-08:002009-01-13T13:46:03.130-08:00Emacs Tip #28: e-blogThere are a number of different packages purporting to enable blogging from Emacs, but most people (including myself) have failed to get any of them to work.I recently heard about: http://code.google.com/p/e-blog/, as a simple blogging package specifically for blogger.This is my first post.Note: It does depend on curl. ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com0tag:blogger.com,1999:blog-2304251215826746968.post-17520533157205180822008-12-10T13:24:00.000-08:002009-04-14T11:24:29.012-07:00stackoverflow.comIf you read Coding Horror or Joel On Software, you already know about stackoverflow.com. In a nutshell, it's a place where you can ask coding questions and receive answers quickly. You can also participate by voting answers up/down and answering questions.stackoverflow.com works really well, the overall design is very simple, clean, and easy to use.The emacs community there is pretty small, butahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com1tag:blogger.com,1999:blog-2304251215826746968.post-56234068172015076862008-12-01T14:38:00.000-08:002008-12-01T17:44:42.885-08:00Emacs Tip #27: midnight-modeI generally have a single emacs session that runs for a couple weeks, up to about 3 months (when work does it's quarterly preventative maintenance reboot), and because of this, I often have dozens of buffers open. Periodically I'd go through them and remove a bunch - mostly to free up memory.Luckily, there's a mode that already does that for you, periodically flushing unused and old buffers:(ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com6tag:blogger.com,1999:blog-2304251215826746968.post-71238654475400104542008-10-22T13:56:00.000-07:002008-10-22T14:08:38.905-07:00Gödel, Escher, BachI'm a Yegge fan-boy, and his most recent post mentioned Gödel, Escher, Bach - the Pulitzer Prize-winning book by Douglas Hofstadter. Which got me to thinking...A couple of programmers/bloggers I respect have the book on their must-have lists: Joel, Stevey. And most programming bloggers refer to it reverently.I tried to read the book shortly after graduating college. I didn't finish it, becauseahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com5tag:blogger.com,1999:blog-2304251215826746968.post-78833476235656492412008-10-10T11:44:00.000-07:002008-10-10T15:26:55.175-07:00Emacs Tip #26: CUA mode (specifically rectangle editing)I'd heard of CUA mode, but generally dismiss it because I don't want the "windows" bindings for cut/copy/paste/undo. But when I saw this video of CUA's rectangle support, I knew this was the way to edit rectangles. Emacs Column Editing from Mark Mansour on Vimeo.To activate in emacs 22.1 - with minimal intrusion (I don't like transient mark mode):(setq cua-enable-cua-keys nil)(ahttp://www.blogger.com/profile/03202031495623868181noreply@blogger.com5