(Note to English-speaking readers: the links entitled Komentarze na tej stronie lead to comment pages.)
In AUCTeX’s LaTeX mode,
C-c C-j is by default bound to
LaTeX-insert-item. By default, it just inserts an
\item on a new line.
I thought that it would be cool to make it insert something else in non-itemize environments. It turns out that I was late, though – the functionality is already there! It is not widely known, however; in particular, it’s not mentioned in the manual. That does not mean, however, that you can’t discover it; the option is called
LaTeX-item-list, and it can be found using
M-x apropos or its more modern cousins, like Icicles or Ivy. Really, you should make a resolution to fire your favourite way of searching through commands and/or options once a day, with some meaningful regex, only to be surprised by some hidden cool functionality you never suspected to exist!
LaTeX-item-list is an alist whose keys are environment names and values are functions inserting that environment’s “variant” of
\item. Unfortunately, just setting it accoridingly in
init.el is not enough; the variable gets rebuilt in every new document. Actually, LaTeX mode initializaton is a complicated business. I know, because I grepped the source for
LaTeX-item-list and found the
LaTeX-common-initialization function. I could grep for that, too, or I could use
debug-on-entry to look at the backtrace and see where it is called. Either way, it turns out that it is called by the
TeX-latex-mode function, which starts the LaTeX mode. (For some strange reason, it is defined with an ordinary
defun instead of
define-derived-mode.) From that it is more or less clear that one good place to modify
As an example, consider this piece of code, which you can put in your
(add-hook 'LaTeX-mode-hook (lambda () (add-to-list 'LaTeX-item-list '("frame" . (lambda () (TeX-insert-macro "pause"))))))
This has an unwanted side effect of putting braces after
\pause. This can also be helped, but that will be the topic of another post.
Today’s post is very atypical. It’s been a long time since the last non-technical post, but here’s another one.
I’ve been blogging here once a week for more than two years now. Considering my very chaotic approach before, I consider it to be a big improvement. It’s no secret that the thing that helped me gain much more systematic approach (not only to blogging) and thus (hopefully) boost my productivity was Beeminder. A few months (maybe even a year) ago I got to the point where (maybe) I no longer need it that much. In fact, the vast majority of my Beeminder goals are pledgeless, i.e., I have no financial incentive to keep doing them. This probably means that I could use Org habits or whatever else might work; still, I value Beeminder, and not only for sentimental reasons: as a geek, I consider its QS part also a very nice thing to have.
But life goes on, and while two years ago, fighting procrastination and introducing regular habits was my main goal, the priority has changed now. (That does not mean that I’m no longer procrastinating. Of course I am, but (1) much less than before and (2) I more or less know an effective cure for that.) One thing I must introduce ASAP is planning; while I did not measure that directly, from some indirect clues I gather that I wasted a substantial amount of time on thinking “what do I do now” – having that preplanned the previous day could help a lot. Also, Beeminder-ish spreading things to “5 minutes per day” as opposed to “30 minutes per week” is not really beneficial (to say the least), and I have already taken some measures to avoid it.
The most important productivity-related thing for me, though, is this. If you thought that beating procrastination is difficult, I have some good and some bad new for you. Good news: it’s not that hard (at least it wasn’t for me). Bad news: the hard part lies somewhere else. Due to certain circumstances (both in my private and professional life) my main time-management-related problem is now different. What I need now is to get rid of as many non-essential things as possible. Now that’s hard, both in terms of material stuff and immaterial time-sinks. Cutting down on watching movies is easy – I never watched many of them anyway. Cutting down on Emacs debugging is hard: I really want (and like) to contribute this way, and I regret I can’t do it currently. (I plan to get back to it and a few other things once the dust settles, i.e., around February.)
In fact, all of that is a very good exercise. I am pretty sure that it will help my advance professionally, but also (more importantly) spiritually. Eventually the only thing that matters is getting safely to heaven. If this sounds a bit egotistic (which it shouldn’t), let me rephrase it this way: eventually, the only thing that matters is practising love. (Sometimes I wonder whether it isn’t a bit like this: for beginners in the faith, the former is the goal, so that they treat the latter as a means. For advanced people (and I hope to get there at some point!), the latter is the goal, and the former is maybe a means to get some motivation. While this is probably an oversimplification at best and a heresy at worst – I said some time ago that I’m not a theologian, and I may as well be mistaken; please correct me if you are more knowledgeable! – I am quite sure that both things are of utmost importance.)
Anyway, it is good to understand that all that productivity stuff is very Catholic at heart: it is about getting rid of things that prevent me from pursuing my main goal. Whether you want to follow advice of Stephen Covey, David Allen (even though he is a member of some suspicious cult), St. Paul, St. Augustine or Jesus Himself – every single one of them says that you should get rid of things that are not absolutely essential, and you’d better do that now. And not because of some hidden agenda, but because it is good for you.
By the way, it interesting that the longer I live, the more I am sure that “Catholic” is more or less a synonym for “reasonable”. (Actually, it’s more; “reasonable” is a subset of “Catholic”.) Whenever I find some good idea (say, about productivity, or basically any other thing), it turns out that the Church has had it for years (and often centuries). Beeminder’s take on what they call “akrasia”? Read St. Paul’s letters. Check. Dividing your time into seven-day chunks and stopping every week to reflect on your goals? Read Genesis. Check. Gamification? Read about St. Margaret Mary Alacoque. Check. Come on, we’ve had it since the seventeenth century, and now it’s been all the rage as something hot and new since, like, five years – take that, you “modern” world!
Of course, it is no wonder that it works like this. Since the Bible and the Church’s teaching is the most accurate description of how a human being works – after all, it’s basically the manual written by the Creator Himself – it would be really surprising if any research contradicted it. And if it happens (and it does indeed – no research is flawless, after all!), I have no doubts who’s right.
One corollary of all that is that trying to enforce something that the Church actively opposes is a very, very risky business; it basically means that the whole initiative is wrong, and will be overturned soon (for some value of “soon” – it may be a decade or two or a century). Currently, the most prominent example seems to be whole “sexual revolution” crap, with abortion, contraceptives and the so-called “gay rights” being the primary things. (One other thing that has been persisting surprisingly long is the concept of divorce – this one seems to need closer to a century.)
And by the way, one reason it works like that is that (contrary to popular belief) the Church does not oppose a lot of things. Actually, she doesn’t oppose anything if she isn’t really, really sure it’s wrong. That’s why the Church does not oppose the evolution theory: while it has – like basically any other scientific theory – its problems, it’s not something that is obviously wrong as a general concept. (One obviously wrong thing about evolution seems to be that it has become more of an ideology than a theory – it seems that anyone trying to raise questions about it is instantly pigeonholed as a crank. This is not how you do science: one of the most valuable things a scientific theory may have is critics, since answering them is how you actually advance science. But I may be wrong here, since I do not read scientific papers on evolution – just twitter posts.)
OK, I think it is time to wrap up this long post. If you happen to like my blog, don’t worry: I do not consider it inessential enough to stop posting here (in fact, I have a nice supply of posts – even if I stopped writing them altogether, I should be fine for a month or so). I also plan to put out more non-technical posts in the near future, but we’ll see how this turns out.
Last week I was coding something Emacs-y, and felt the need of a
format-like function. It would get a string with embedded “control codes”, like
%h, and then output a string with these “control codes” replaced by actual content. Writing something like that is not particularly difficult, but since I wanted to be able to also escape the percent sign by writing
%%, I didn’t really feel like reinventing the wheel (and doing it elegantly and efficiently might be a tad tricky anyway). I asked a question on the help-gnu-emacs mailing list, and voilà! Here is the
format-spec function. It accepts two arguments: a format-like string and a specification. The latter is an alist mapping characters to values. Here is an example:
(format-spec "%n %v %p %o." '((?n . "A dog") (?v . "jumps") (?p . "over") (?o . "the fence"))) (format-spec "%n %v %o." '((?n . 7) (?v . 8) (?o . 9)))
Notice that the values need not be strings – other objects are fine, assuming that they are printable as in
(format "%s" ...). Also, you can put any width/precision and left-align specifiers (as you would in
(format "%s" ...), which is called underneath by
For the sake of completeness, let me also notice that if you want to put variables in the
format-spec specification, you either need to use backquoting and unquoting or construct the specification list by the
format-spec-make function (quod vide).
Once again, Emacs customizability shines – also when I want my code to be as customizable as Emacs’ own one.
(Więcej means More in Polish; click it to see older entries.)