Content AND Presentation

Last edit

Summary: remove obsolete info about Polish words (they've been translated to English a long time ago anyway).

Deleted:

< (Note to English-speaking readers: the links entitled //Komentarze na tej stronie// lead to comment pages.)

Deleted:

< (//Więcej// means //More// in Polish; click it to see older entries.)


2018-04-21 counsel-rg and symbol at point

Continuing my streak about counsel, I had a small a-ha moment a few days ago.

I often use counsel-rg. It was rather annoying for me that I had to mark the function or variable name at point, copy it to the kill ring, invoke counsel-rg and then yank it back.

Until I realized that all this was unnecessary. It turns out (and this is even mentioned in the manual) that you can use the normal feature of Emacs, which is clairvoyance. No, seriously. When Emacs presents you with some choice to be made in the minibuffer, usually you can press M-p to go back in the history, and then M-n to go forward again. However, if you start with M-n, you move in the minibuffer history into the future, which is a probable “dwim” (do-what-I-mean) choice. If you run counsel-rg with active region, this means that M-n will fill the minibuffer with its contents. If the region is not active, it will be the symbol or url at point.

By the way, a similar thing works in swiper, too. Here we can even have two choices (at least in programming modes): just the symbol at point or the symbol at point surrounded by \_< ... \_> (which makes sense, since this means boundaries of a symbol).

Anyway, the tradition continues: if you use Emacs and at some point think “I’d like Emacs to have some feature”, chances are pretty good that it’s already supported.

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2018-04-15 counsel-org-clock

Some time ago I blogged about my Org-mode hydra. It turned out that that a link to that short article was posted to Reddit, and one of the commenters pointed out his counsel-org-clock package.

I’ve been blogging about Oleh Krehel’s Emacs-related stuff many times. This time we have a package not authored by him, but based on counsel. (Unfortunately, counsel-org-clock is apparently not in Melpa, so you have to download it directly from Github.)

It is basically a org-clock-in with a prefix argument of C-u, i.e., clocking in a task from history, on steroids. The main entry point is the command counsel-org-clock-context. When a clock is on, it just displays the path to the currently clocked entry, so that you can easily jump to it or any of its ancestors. The interesting part is what happens when there is no clocking at the moment: it displays the clock history using Ivy instead of the default Org-mode interface (which I strongly dislike), so you can just type a few characters to narrow down and select the thing to clock.

Even better, in either case you can press M-o to get a menu of possible actions to perform of the currently highlighted entry. You can clock in (the default action being jumping to the selected entry), change the todo state, or narrow to the selected entry, or set a tag or property on it, and do a few other things.

One drawback was that it turned out that you can’t change the default action to clocking in. I rolled up my sleeves and implemented a proof-of-concept solution to this and submitted a PR. Within a few hours the author fleshed my solution out and it is now available in the package.

One caveat: it didn’t work for me out of the box, somehow triggering an error. A simple M-: (setq org-clock-history nil) helped, and now I’m building my clock history from scratch (which is not a big deal, of course).

I have now added counsel-org-clock-context to my Org-mode hydra, just to see how useful it’s going to be for me. (Postscript after a few days: I’m more and more in love with this, although it didn’t replace my Org hydra – I still use org-clock-in-last a lot, for instance. But I’m not coming back to plain Org clock history at all.)

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

2018-04-09 counsel-yank-pop

Some time ago I wrote a tip about yanking, and I was informed in a comment that helm has helm-show-kill-ring, which is a replacement for M-y. Turns out that the Ivy suite has counsel-yank-pop, which is a similar thing. Even better, instead of binding M-y to it manually, you can just turn counsel-mode on, and many Emacs commands will be automatically remapped to their counsel equivalents. Nice!

CategoryEnglish, CategoryBlog, CategoryEmacs

Comments on this page

More...

CategoryEnglish, CategoryBlog