Posts

Showing posts with the label emacs

My New Favorite Phone Game: termux

 A lot of people when bored pull out their phone and play games.  Games just don't do it for me for some reason.  I mean, I played chess for a while, and recently I tried Shoot Bubble and 5 Dice (generic Yahtzee), but for some reason I always forget I even have them available and I end up just scrolling Twitter :-/  My feed is pretty good, if someone gets overly political or negative (usually its a combination of the two) I block them, but stuff still leaks in.  Usually if Twitter is holding my attention for a long time it's because it's making me angry.  I don't like that.  I think I've found a better solution for when I'm bored and pull out my phone: termux . Termux is a linux command-line environment for Android.  It's a kinda like wsl (or cygwin if you are old like me) or Terminal.app, but for your phone.  It's almost linux but not quite.  Normally I find that very frustrating, especially if I'm trying to get real work done (you may ...

How To Retroactively Annex Files Already in a Git Repo

UPDATE : With current versions of git, I no longer recommend git annex or git LFS unless you really need to store your large files on a separate server from your git repository. Just add your large files to git like any other file and when you clone, you can avoid downloading the full repository history with git clone --filter=blob:none and use git as normal. Table of Contents How To Retroactively Annex Files Already in a Git Repo First Tries: filter-branch, filter-repo Success with git rebase –interactive Added binary files Deleted binary files Modified binary files Moved binary files Dealing with Tags Clean Up and Results How To Retroactively Annex Files Already in a Git Repo In my last post I talked about how surprisingly easy it is to use git annex to manage your large binary files (or even small ones). In this post, I'm going to show how hard it is to go back and fix the mistake you made when you decided not to learn and use git annex at the start of your p...

Fixing xref-find-references

I was annoyed that xref-find-references searched more than the files in the TAGS file (it seems to search everything below the top level directory of the TAGS file?) so I went looking for a fix. I found that apparently my emacs knowledge is out of date (the fact that it's xref now and not tags was my first clue). I couldn't find any way to customize xref-find-references . Instead I found people referring to project, ivy, helm, confirm, The Silver Searcher (ag), ripgrep (rg), and dumb jump. I didn't go all the way and get into project or ivy or any of the others, but I did download ag and rg and tried them from a command-line outside of emacs and saw exactly what I was expecting xref-find-references to do. I figured all I needed was to replace xref-find-references with one of those. I got ag.el installed and working before any of the ripgrep packages (there's both rg.el and ripgrep.el) and then struggled to remap M-? to call ag-project instead of xref-find-refe...

Quick Thoughts on Creating Coding Standards

Introduction No team says, "write your code however the heck you want." Unless you are coding alone, it generally helps to have an agreed upon coding standard. Agreeing upon a coding standard, however, can be a painful process full of heated arguments and hurt feelings. This morning I thought it might be useful to first categorize coding standard items before starting the arguments. My hope is that once we categorize coding standard items we can use better decision criteria for each category of items and cut down on arguing. Below are the categories I came up with really quickly with descriptions, examples, and decision criteria for each category. Feedback is welcome in the comments. Categories of Things in Coding Standards Language Specific Pitfalls Characteristics​ not subjective, easy to recognize pattern well recognized in the industry as dangerous people have war stories and about these with associated scars to prove it Examples no multiple dec...

Make Terminal.app Useful for Emacs

Running emacs -nw in Terminal.app on my Mac has been pretty frustrating, until today. To fix the experience, download and install KeyRemap4MacBook (I sure hope it's not malware). Click on "Change Key." Scroll down until you find "For Applications." Expand that to "Enable at only Terminal" and select "Change Command_L to Option_l." Expand "Change Slash(/) Key" and select "Control+Slash(/) to Control+Underscore(_)." You might also want to select "Switch next and prev tab in terminal with shift and arrows (like Gnome term)." All better.

My .emacs is now in Mercurial

A while ago I decided to start maintaining my .emacs file under revision control. I picked git because it seemed like the cool thing to do. I put it on gitorious so that I could easily sync it with my home and work machines, and it was public in the off chance that it might help out some other emacs user. Today I converted it from git to mercurial, because for some reason hg incoming is more intuitive and easier for me to remember than git fetch && git log ..origin/master Maybe I'm weird that way. Anyway, the new repo is on bitbucket . That is all.

Email with Thunderbird, Compose with Emacs

My Mac let's me use emacs keyboard shortcuts everywhere. I'm really sad that I don't get that in Linux. How the universe ever got into this state is beyond my comprehension. Mail.App has gotten me hooked on emacs keybindings when typing emails especially. The solution in Linux, it turns out, is to just use emacs. I already have It's All Text for Firefox, with emacsclient as the editor. I just found External Editor for Thunderbird, with emacsclient as the editor and tbemail-mode for extra goodness. I think that'll do.

Emacs Now Has Uptime

I noticed a few places mentioning that emacs 23.2 has been released , and I went and read the changelog and noticed a few cool new things. Probably the best was down in the emacs 23.1 section. Yes, emacs now has an uptime command, M-x emacs-uptime . That is awesome. My current emacs uptime (on my work machine): 4 days, 21 hours, 52 minutes, 47 seconds. What's yours? P.S. if you aren't using emacs-server and emacs-client yet, you probably don't stand a chance in this contest. P.P.S. Hmm, did Steve Yegge have anything to do with this new feature?

New Job, New Focus

I have a new job! I am now a verification engineer at a relatively new hardware company in Utah. I worked on digital design and verification stuff back during internships in college and then for the first few years that I worked full-time. Then about five years ago I switched over to embedded software. It's fun to be back in the hardware design world. Better verification and system modelling was a hot topic five years ago, and it looks like a lot of progress has been made in the intervening years. It's really cool to see. Another big win with the new job is, no more windoze! ASIC designers know a good development environment runs on Linux ;-) I mostly use this blog to write down helpful reminders for myself, and as a start, here's my first verilog tip. Code browsing with ctags works for verilog too! I used find to get a list of all our verilog files and put that in a file called, file-list.txt. Then I generated tags like so: ctags -e --verbose --language-for...

Emacs next-line Changed Behavior?

I just made a macro to do some quick-n-dirty editing and noticed that c-n, or next-line, acts funny. If the line is long and wraps, it goes to the next visual line, not the actual next line of text (as delimited with a newline). Inconsistently, c-e, or move-end-of-line, still goes to the end of the actual line, not to just before it wraps (moves to the newline). This is with emacs 23.0.60.1, which isn't an official release, so maybe that's just what I get for being bleeding edge. Anyway, it was kind of weird and I wanted to document it. I like the old behavior of c-n better, but the c-e thing allowed my macro to still be possible. Some good that came of this was that markhepburn noticed this too , and google picked it up, and now I can see all the other cool emacs discoveries he has posted in his twitter feed.

XO Post Upgrade

When you run olpc-update to upgrade the software on your XO laptop, you lose some of your customizations (which I just did ). Here's what I've customized so I have a quick reference to get it all back next time. Set the timezone : su sugar-control-panel -s timezone 'America/Los_Angeles' Set a root password: su -l passwd This allows me to ssh to the XO (as root, I know, I know) which at least allows me to use my nice desktop keyboard and monitor to do most of the rest. I tried setting the user account password instead once, but it seems like Sugar wouldn't start after that. This page seems to indicate that you should be able to do that (now?) though. I'll have to try it again. Set up quake terminal (scroll down the page a bit). I keep a copy of the quake_terminal.txt file in my home directory on the laptop. To set it up I just do this: su -l cp /home/olpc/quake_terminal.py /usr/share/sugar/shell/view/quake.py Then apply this patch to /usr...

Beat the Save Habit

It only takes one unfortunate program crash where you lose a lot of work to teach you the importance of saving often. I use emacs most of the time, and I had developed a nearly subconscious, paranoid habit of hitting c-x c-s every 5 seconds or so while working. I was starting to catch myself before hitting that save-buffer shortcut even when I was typing in other applications: instant messenging, web page forms, you name it. Meanwhile, I also started noticing applications that didn't require me to tell them to save my precious work. Gmail and blogger come to mind right a way. " Why couldn't emacs do the same? " I wondered. After hashing it out in that blog entry and on the emacs wiki , I added the following to my .emacs file, and I am happy to report that my twitch is gone: (defun save-buffer-if-visiting-file (&optional args) "Save the current buffer only if it is visiting a file" (interactive) (if (buffer-file-name) (save-buffer arg...

Source Code Browsing

A co-worker recommended GNU Global for browsing source code a few days ago. It was pretty easy to set up. Install it and then go to the root of your source tree and type gtags . Then you can run global on the command line and try it out. Try things like: global funcName global -x funcName global -rx funcName global -sx varName That should give you the idea that it can find a function definition and all its references, or a variable name and all its references pretty quickly. Very handy. There is an emacs interface as well. Load gtags.el (comes with global), open a file, and do M-x gtags-mode . c-h m will show you the commands gtags-mode provides for doing the same thing we just did on the command line. I'm not sure if I'm going to switch to using global/gtags. I already use a combination of cscope and Exuberant ctags , both of which have their strengths, and both of which have emacs interfaces, naturally. They all seem to have troubles parsing out tags...

My c-x c-s Muscles Are Getting Tired.

I've used some of the online office apps a bit, such as Google Docs, and I really like that you don't have to continually save your work. They take care of that for you. The blogger web interface that I'm using to type this entry does the same thing. A few people I work with are big Microsoft One Note fans, and it doesn't even have a save button. I believe it's time for emacs to save my files for me. I have a c-x c-s twitch that I'd like to get rid of. I hunted around a bit, thinking that I couldn't have been the first emacs user to think of this, but I didn't have much luck. It turns out that Emacs does save your work for you automatically , but it's not quite what I'm looking for. It saves to separate back up files that you have to use special commands to recover information from, and it still bugs you about saving whenever you do things like compile or exit. Of course I want to save my work! Is there really no good auto-save featur...

Pretty Emacs for Gutsy

Pretty fonts for emacs on Gutsy Gibbon was easy to fix (unlike the sound problem I'm having). Just follow the instructions for pretty emacs here .

Highlight "#if 0" Region of C, C++

My vim using co-workers enjoy a useful feature that I haven't yet found in emacs. A common thing to do to comment out large sections of C or C++ code is to put an #if 0 , #endif pair around them. Vim seems to know to change the code highlighting for those regions. Emacs does not. I searched google and came across this suggestion to use hideif.el , which kinda works, but I'm not satisfied. It doesn't automatically change the color of the text like commenting it out does, you have to run the hide-ifdefs to get it to change the color, and you have to re-run it if you do any more editing. I want it to work just like other font-locking in emacs, automatically. Does anyone know how to do this?

A Better Shell

The product I'm helping to develop at work has a TCP service that you can telnet to and get a simple command-line shell for development purposes. In our firmware we have a simple framework for writing commands that can then be called from this shell. You can do all sorts of handy things like check sensors, run calibrations, query ASIC registers, read and write memory locations, and so forth. We also use this to play with different configurations and new features before making them permanent. The big downside to this shell is that, well, let's just say that for anyone used to a modern shell like bash, this one is stone-age. There is no command history, no command-line editing except to backspace and retype, and no scripting. This can get very frustrating when you have a command or set of commands that you need to run over and over. Especially when you start using fairly complicated ones with hexadecimal memory addresses, bit masks, and other esoteric parameters. Sure, so...

Resolve Bazaar Merge Conflicts with Emacs

How to fix bizarre merge conflicts with emacs will be in a different chapter. Here you will just find tips for working with the Bazaar revision control system , also known as, bzr. This assumes you are fairly comfortable with the basics of bzr and emacs . When you do a bzr merge to pull in changes from a different branch (try bzr pull first, it will tell you if you need to bzr merge instead), it's possible that conflicting edits have been made to the files you are versioning. In that case bzr will tell you about it, and drop three new files in your directory tree for each file with conflicts. They will be named, file.THIS , file.OTHER , and file.BASE . "Whoa! Scary! What do I do with all of these?" you might say to yourself. I'm here to answer that question, with a handy emacs tool called ediff. Open emacs and and type M-x ediff-merge-with-ancestor . It will ask for three files, which you should give in this order: file.THIS , file.OTHER , and file.BASE . ...

Random Reading

This morning I somehow ended up on a string of random readings on the good ol' world wide web. It was one of those times where I can't even remember how I got started, but I ended up reading a few blog posts on some blogs that I've never really come across before, but were totally awesome. And I guess that's how this whole web logging thing got started. People finding cool stuff and feeling the need to write it down, because it was just so cool. So, as best as I can retrace my steps, I was looking for something emacs related, or maybe just reading the Planet Emacsen feed, but I found this wonderful emacs blog that I hadn't really noticed before. Specifically I found the imenu feature. Wow, that's just so handy. Especially when you bind it to your right mouse button . Somehow I also ended up on this googler's blog . I realized I had been there before because of Joel's story on Windows XP shutdown craziness . But what was more interesting was...

Best Little Emacs Tutorial Ever

I discovered Steve Yegge's long essays and blog posts a while ago. I think it was his Effective Emacs post that I first came across actually, but he's written a whole bunch of interesting geeky stuff. So interesting that I find myself telling my wife about it. So interesting that, even through my pathetic retelling, it actually interests my wife (a little), who isn't even a computery geeky person. I wish I wrote stuff half that interesting. Go check his blog out, because it's just so interesting. Have I mentioned it's interesting? So anyway, I was inspired to write, and publicly thank him for his recent little emacs tutorial . Very educational and entertaining. What more could you want? It just so happens that I'm in the middle of a repetitive editing task, using emacs, of course, and I took a break for lunch and read this tutorial and was inspired to write some interactive lisp functions to make it easier. It took about 30 seconds (after, I don'...