Alvaro Ramirez: Its all up for grabs, compound with glue

14 July 2024 It's all up for grabs, compound with glue

I've written before, once you learn a little elisp, Emacs becomes this hyper malleable editor/platform. A live playground of sorts, where almost everything is up for grabs. You can inspect and tweak behaviour of just about anything to your liking.

While the compounding benefits of using your favourite Emacs utilities are evident over time, learning elisp takes the compounding effect to another level. It empowers you to have those aha moments like "if I could just wire this awesome utility with that other one, it'd be perfect for me" and enable you to act on it.

Take, for example, symbol-overlay and multiple-cursors. Two Emacs packages I've been using for years. The first one is a feature you've likely experienced on your favourite IDE or editor without thinking too much about it. Placing your editor cursor on a variable automatically highlights its usages. It's one of those lovely features with zero learning demands.

overlay-symbol.gif

The second utility, multiple-cursors, does demand some learning but can be so fun to use once you get the hang of it. Below is a little multiple cursor demo I used recently in a reddit comment, but you really should check out Emacs Rocks! Episode 13: multiple-cursors (stick around for the ending).

mc_x2.gif

So where am I going with this? While symbol-overlay offers a mechanism to rename symbols via symbol-overlay-rename, I prefer multiple-cursors for this kind of thing… "if I could just get symbol-overlay to tell multiple-cursors where to place my cursors, it'd be just perfect for me".

I've been wanting this tweak for some time. Today's the day I finally act on it. I had no idea how to go about it, but opening symbol-overlay.el (via M-x find-library symbol-overlay) and browsing through all functions (via imenu) yields the first piece I needed: symbol-overlay-get-list.

imenu.png

(defun  symbol-overlay-get-list (dir  &optional symbol exclude)
   "Get all highlighted overlays in the buffer.
 If SYMBOL is non-nil, get the overlays that belong to it.
 DIR is an integer.
 If EXCLUDE is non-nil, get all overlays excluding those belong to SYMBOL."
  ...)

Let's take symbol-overlay-get-list for a spin, courtesy of M-x eval-expression, and see what we get out of it:

eval.gif

With a list of overlays, we now know where to tell multiple-cursors to do its thing. For the second piece, we needed to peek at any of the multiple-cursors commands I already use. I happen to pick mc/mark-all-like-this to examine what's under the hood.

(defun  mc/mark-all-like-this ()
   "Find and mark all the parts of the buffer matching the currently active region"
  (interactive)
  (unless (region-active-p)
    (error  "Mark a region to match first."))
  (mc/remove-fake-cursors)
  (let ((master (point))
        (case-fold-search nil)
        (point-first (< (point) (mark)))
        (re (regexp-opt (mc/region-strings) mc/enclose-search-term)))
    (mc/save-excursion
     (goto-char 0)
     (while (search-forward-regexp re nil t)
       (push-mark (match-beginning 0))
       (when point-first (exchange-point-and-mark))
       (unless (= master (point))
         (mc/create-fake-cursor-at-point))
       (when point-first (exchange-point-and-mark)))))
  (if (> (mc/num-cursors) 1)
      (multiple-cursors-mode 1)
    (mc/disable-multiple-cursors-mode)))

The star of the mc/mark-all-like-this attraction is mc/create-fake-cursor-at-point, used to create each cursor. If we can just iterate over the overlays, we'd be able to create a fake cursor per overlay. There's some additional logic needed to ensure all fake cursors are placed in the same relative position within symbol (using an offset). Finally, we need to enable multiple-cursors-mode.

We put it all together in ar/mc-mark-all-symbol-overlays:

(defun  ar/mc-mark-all-symbol-overlays ()
   "Mark all symbol overlays using multiple cursors."
  (interactive)
  (mc/remove-fake-cursors)
  (when-let* ((overlays (symbol-overlay-get-list 0))
              (point (point))
              (point-overlay (seq-find
                              (lambda (overlay)
                                (and (<= (overlay-start overlay) point)
                                     (<= point (overlay-end overlay))))
                              overlays))
              (offset (- point (overlay-start point-overlay))))
    (setq deactivate-mark t)
    (mapc (lambda (overlay)
            (unless (eq overlay point-overlay)
              (mc/save-excursion
               (goto-char (+ (overlay-start overlay) offset))
               (mc/create-fake-cursor-at-point))))
          overlays)
    (mc/maybe-multiple-cursors-mode)))

and with that, you finally get to see it all in action…

symbol-overlay-meets-multiple-cursors.gif

Unrelated - Want your own blog?

Like this blog? Want to start a blog? Run your blog off a single file. Write from the comfort of Emacs (or your favourite text editor) and drag and drop to the web. I'm launching a blogging service at lmno.lol. Looking for early adopters. Get in touch.

-1:-- Its all up for grabs, compound with glue (Post)--L0--C0--July 14, 2024 08:30 PM

Irreal: A Spelling Transient

Over at DyerDwelling there’s another nice example of using a transient menu to capture the keystrokes for a set of packages. This time it’s for some spelling related packages. The author couldn’t make up his mind on what keystrokes he wanted for the various commands so he decided to implement a menu instead.

If you’ve been reading Irreal lately, you know that I’m a big fan of this approach, especially as realized by Charles Chou’s Casual Suite. Nonetheless, I’m not sure that a menu is the best solution here. At least not for commands that do things like correct the last misspelling. I use commands like that constantly and want them instantly available without having to wade through a menu.

Still, we can have it both ways. There’s no reason to restrict yourself to one approach. You can have a menu as described in the DyerDwelling post and still specify keybindings for the commands you use all the time. And to be fair, you can also think of the sequence to invoke the menu and the option choice as a single, slightly longer, key sequence.

I’m again impressed at how easy it is to set up a transient menu. Take a look at the code in the DyerDwelling post to see for yourself.

-1:-- A Spelling Transient (Post jcs)--L0--C0--July 14, 2024 03:32 PM

Anand Tamariya: Annotate completion candidates (GNU Emacs)


GNU Emacs supports annotation for completion candidates. An annotation is a small bit of useful information shown next to a completion candidate which a package developer can use to provide additional help to the user while making a selection. e.g. while selecting a command, this is usually the keyboard shortcut.

In the following example, annotation is used to display a sample text with the candidate font-family applied. 

(defun test ()
  (interactive)
  (let* ((completion-extra-properties
          `(:annotation-function
        (lambda (a)
          (propertize " (OIly10)" 'face
              `(:family ,a :background "grey"))))))
    (completing-read "Font family: " (font-family-list))
    ))

 

By default, Emacs uses completions-annotations face for the annotation. Use the following patch to skip changing the face when the annotation already has a face attached.

modified   lisp/minibuffer.el
@@ -1754,8 +1754,10 @@ completion--insert-strings
               (let ((beg (point))
                     (end (progn (insert (cadr str)) (point))))
                 (put-text-property beg end 'mouse-face nil)
-                (font-lock-prepend-text-property beg end 'face
-                                                 'completions-annotations)))
+                (or (get-text-property beg 'face)
+                    (font-lock-append-text-property beg end 'face
+                                                    'completions-annotations))
+                ))
         (cond
          ((eq completions-format 'vertical)
           ;; Vertical format

 

-1:-- Annotate completion candidates (GNU Emacs) (Post Anand Tamariya (noreply@blogger.com))--L0--C0--July 14, 2024 09:24 AM

Irreal: Org Template Fundamentals

Forward

Does anyone know what happened to Emacs Elements? As I was getting ready to publish this post, I notices that the below linked video was gone and that Google said it had been deleted by the author. On further investigation, I see that the entire playlist is gone.

I did find this post on the Emacs subreddit but it doesn’t have any information: just others wondering what happened to the site, and mourning its loss. If you know anything, please leave a comment.

My original post is below but, of course, none of the links lead anywhere interesting.

Original Post

Emacs Elements has a nice video up on Org mode capture templates. This video concentrates on the structure and meaning of the templates.

Org templates are one of the most useful ways of using Org to capture and record various types of data. I use them to capture tax, health, journal, TODO, email, and blogging data. They’re easy to adapt for capturing data in several formats and to annotate the captured information.

Building the templates is a bit fussy and you have to get them just right or they won’t work. That said, they have a reasonable format and aren’t too hard to learn. Even if you don’t want to build them yourself you can still use the Emacs configure subsystem.

The video is relatively short—7 minutes, 37 seconds—so there’s no point in recapitulating it here. Spend a few minutes with it to find out the sorts of things that are possible and use the excellent Org documentation to fill in any blanks.

-1:-- Org Template Fundamentals (Post jcs)--L0--C0--July 13, 2024 03:12 PM

James Cherti: Emacs Evil Mode: Disabling the automatic removal of spaces after leaving Insert mode

5/5

By default, Emacs evil-mode removes newly inserted spaces when exiting insert mode. However, some users may find this disruptive to their workflow. This is particularly true for those who edit file formats where trailing spaces are significant or who simply prefer to manage whitespace manually.

To prevent the automatic removal of trailing spaces when leaving insert mode, add the following Elisp code to the Emacs init file:

(with-eval-after-load 'evil
  (defun my-evil-disable-remove-spaces ()
    "Disable automatic removal of trailing spaces in `evil-mode'."
    (setq-local evil-maybe-remove-spaces nil))

  (add-hook 'evil-insert-state-entry-hook #'my-evil-disable-remove-spaces))

The function above sets the evil-maybe-remove-spaces variable to nil when entering insert mode, preventing the evil-maybe-remove-spaces function from deleting whitespace after leaving insert mode.

The evil-insert-state function, which Evil uses to switch to insert mode, behaves as follows:

  • When entering insert mode: It sets the evil-maybe-remove-spaces variable to t.
  • When exiting insert mode, it calls the evil-maybe-remove-spaces function, which removes trailing spaces if the evil-maybe-remove-spaces variable is set to t. Because the my-evil-disable-remove-spaces function above sets the evil-maybe-remove-spaces variable to nil when entering insert mode, it prevents the evil-maybe-remove-spaces function from deleting whitespace after leaving insert mode.

If you want to compare the behavior before and after the function above, use whitespace-mode. This mode visually highlights different types of whitespace characters, such as spaces, tabs, and newlines, making it easier to see the differences.

Conclusion

Customizing evil-mode with the simple piece of Elisp code above can prevent the automatic removal of trailing spaces when exiting insert mode. This adjustment allows for better control over whitespace in files.

-1:-- Emacs Evil Mode: Disabling the automatic removal of spaces after leaving Insert mode (Post James Cherti)--L0--C0--July 13, 2024 02:12 PM

Magnus: A function for jumping to a project TODO file

I've had org-projectile in my config since the beginning, and while it's worked nicely for me in my main config it gave me some grief when I played around with elpaca the other week.1

I tried to get the install instructions to work, but kept on getting errors when loading my config. Given that I only use it for one thing, to open the file TODO.org in the current project's root, I decided to just write a function for doing that instead.

(defun mep-projectile-open-todo ()
  "Open the project's todo file."
  (interactive)
  (if-let* ((proj-dir (projectile-project-root))
            (proj-todo-file (f-join proj-dir "TODO.org")))
      (org-open-file proj-todo-file)
    (message "Not in a project")))

Footnotes:

1

This was the second time I gave up on using it instead of straight, but that's another story.

-1:-- A function for jumping to a project TODO file (Post)--L0--C0--July 13, 2024 08:24 AM

Marcin Borkowski: Dedicated windows

There are some features of Emacs which you can read about in the manual and go “huh? what is that about? who’d ever need it?”, and then later turn out to need exactly them. Recently I learned that dedicated windows are just like that.
-1:-- Dedicated windows (Post)--L0--C0--July 13, 2024 06:14 AM

Emacs APAC: Announcing Emacs Asia-Pacific (APAC) virtual meetup, Saturday, July 27, 2024

This month’s Emacs Asia-Pacific (APAC) virtual meetup is scheduled for Saturday, July 27, 2024 with BigBlueButton and #emacs on Libera Chat IRC. The timing will be 1400 to 1500 IST. The meetup might get extended by 30 minutes if there is any talk, this page will be updated accordingly. If you would like to give a demo or talk (maximum 20 minutes) on GNU Emacs or any variant, please contact bhavin192 on Libera Chat with your talk details:
-1:-- Announcing Emacs Asia-Pacific (APAC) virtual meetup, Saturday, July 27, 2024 (Post)--L0--C0--July 13, 2024 12:01 AM

James Dyer: Creating a Spelling Transient

I really want to finally get to grips with my spelling / dictionary set-up.

I’m happy with jinx instead of flyspell. I like powerthesaurus and, of course, dictionary-lookup-definition. It is mainly the keybindings I want to finally settle on. I have been moving them around for a while now but haven’t really established something comfortable.

Now Emacs 29 comes with transient, which is the keyboard-driven interface used by Magit, I am going to see if I can fit my spelling keybindings into a more menu-driven system. I have tried Hydra in the past but found I wasn’t really using it. Now that transient is built-in and the syntax seems simple, let’s give it a go!

Here are my original keybindings:

(use-package jinx)
(use-package powerthesaurus)
(global-set-key (kbd "M-s y") 'powerthesaurus-lookup-synonyms-dwim)
(global-set-key (kbd "M-s a") 'powerthesaurus-lookup-antonyms-dwim)
(global-set-key (kbd "M-s x") 'jinx-mode)
(global-set-key (kbd "M-s c") 'jinx-correct)
(global-set-key (kbd "M-s d") 'dictionary-lookup-definition)

and converted into :

(use-package jinx)

(use-package powerthesaurus
  :init
  (require 'transient)
  (transient-define-prefix my/transient-spelling ()
    "Spelling commands"
    ["Spelling"
      ["Lookups"
        ("y" "Synonyms" powerthesaurus-lookup-synonyms-dwim)
        ("a" "Antonyms" powerthesaurus-lookup-antonyms-dwim)]
      ["Spelling Tools"
        ("x" "Jinx" jinx-mode)
        ("c" "Jinx correct" jinx-correct)]
      ["Dictionary"
        ("d" "Lookup" dictionary-lookup-definition)]
      ["Miscellaneous"
        ("q" "Quit" transient-quit-one)]])
  :bind
  ("C-c s" . my/transient-spelling))

and produces the following menu:

Well that was pretty simple, lets see how this goes and if I might then think about translating some more of my keybindings to transient menus.

-1:-- Creating a Spelling Transient (Post James Dyer)--L0--C0--July 12, 2024 07:25 AM

Protesilaos Stavrou: Emacs: Tell Org which linked files to open externally

When Org resolves the file system path to a link that uses the file: hyperlink type, it has a mechanism to decide whether to open that file in Emacs or an external program. Here is some sample Org markup:

A link to [[file:/path/to/test.html][an HTML file]] will open outside Emacs.

The idea is that some files are best handled by a specialised program, such as a video with a media player. Generally useful, yes, though there are cases where we may want to use Emacs. Hence the user option org-file-apps.

This option lets us specify a list of cons cells, each of which consists of a file matcher and method as (MATCHER . METHOD). The doc string describes the technicalities. For my case, the MATCHER is a regular expression that targets the file type extension, while the METHOD is the emacs symbol. Thus:

;; Tell Org to use Emacs when opening files that end in .html
(add-to-list 'org-file-apps '("\\.html\\'" . emacs))

The add-to-list function is especially useful here, because it appends the element to the existing value of the list. This is what we probably want in this case as the default value of org-file-apps has some reasonable associations already.

I learnt about this after troubleshooting a case with denote: link types in Org files (denote: links are designed to behave like the file: type). Org would open HTML files in the browser, making it awkward to get to an Emacs buffer from where to edit the code. With Denote in particular, it is common to rename files of any file type (images, videos, PDFs, …) to have the Denote file-naming scheme and then link to them from an Org buffer. It is also possible to generate new files in any writable file type, subject to some configurations. This was my case, with the use of HTML files.

[ I also wrote a relevant entry about this in the Denote manual. ]

Thankfully, org-file-apps is there to (i) let us enjoy the power of opening some file: (or denote:) links externally while (ii) deciding when we want those to be in an Emacs buffer instead.

-1:-- Emacs: Tell Org which linked files to open externally (Post)--L0--C0--July 12, 2024 12:00 AM

İsmail Efe: My Writing Tools

My Writing Tools

İsmail Efe Top

2024-07-12

I love writing, it helps me empty my mind and improve my ability to express myself. While I enjoy writing digitally the most, I have to write to a paper often because of school and other circumstances.

I have a few friends that accompany me while I write. I acquired these friends throughout my life, each has their own unique stories and reasons. They make writing easy and fun for me. I will introduce them chronologically.

Rotring 500

If you want to learn more, you can check out my previous post where I talked about this pen in more detail.

This is a mechanical pencil that I bought by chance when I was preparing for university exam. I solved every test, mock exam, and problem with this pen. It is lightweight but has a nice build quality. While it is cheap, it doesn't feel like it. When I first saw this pen I fell in love with it's pure black body and it's italic red font.

When I look at it objectively, it may not be the most ergonomic pen, but I enjoy using it so much that any discomfort from writing for long hours doesn't bother me a bit. I usually notice the fatigue in my wrists after I am done writing.

I also used it a lot during my preparation year at university and my first year. I entered all of my exams with it and always carried it with me. I still use it from time to time but my newly bought Rotring 800 became the primary mechanical pencil I use.

I recommend it to everyone who wants a good-looking mechanical pencil that is light and long lasting.

Pensan Büro

While I haven't seen this pencil anywhere other than Türkiye, it is probably the most popular pencil here. It is a dirt cheap ballpoint pend that is usually in blue color. Every Turkish person probably used it at some point in their life. I can't stress this enough, this particular pen is sold and used everywhere. From government offices to sports-books.

In addition to it's availability, there is another big reason, this thing SLIDES. It is so smooth to write on any surface.

I use a ballpoint pen when I want to go crazy. Creating diagrams, writing questions in bold and sketching solutions. My main goal is writing ideas fast. And this pen is the best when it comes to that.

It is also really light and has a pen clip. You can attach it's cap to it's back and extend it. What else can you want from a pen?

HHKB Professional BT

I was really into custom keyboards from 2019 to 2023. I would follow custom keyboard youtubers and subreddits. I would listen to tons of typing tests and would dream of "end-game" keyboards like Keycult and TGR.

Luckily the dollar exchange rate was somewhat stable when I started the hobby and I got the chance to try a lot of custom boards and switches. While I did try a lot of different mechanical keyboards, there was a one keyboard that I wasn't able to try. It was a keyboard called Happy Hacking Keyboard (HHKB) and unlike all of the keyboards I used in the past, it didn't have mechanical switches. Instead, it used a patented electrostatic capacitive Topre switch. These switches were produced by Topre Corporation in Japan and didn't seem to have a counterfeit alternative that I could order from Aliexpress to try.

These switches were used by a couple of different keyboard brands. The most popular one was the HHKB and they were praised as the ultimate keyboard because of their 'godly feel' and the layout. There were a lot of custom keyboards that used the HHKB layout. You can learn more about the HHKB layout in HHKB's official blog post.

Another characteristic of a HHKB keyboard is how expensive they are. The base model's price starts at 300 dollars and they are especially expensive in countries that don't have a official distributor because of the heavy import fee.

For a really long time I searched local second-hand sites for one and finally found it in Jan 2023. I bought it in person from a foreign guy that bought it a couple of years before, in his trip to Japan. He sold it to me for a fair price and I finally had a HHKB keyboard.

Was it as good as people deemed it to be? Yes, it was. The keys felt heavenly and the layout was great. I retired my custom keyboards and used the HHKB primarily. While I didn't carry it with me everywhere, it felt special every time I had the chance to type on it. I loved that thing.

After using it for a year I sadly developed carpal tunnel syndrome. I would get heavy wrist pain after a couple of minutes of using it. Even though it saddens me, I had to stop using it.

Logitech Wave Keys

While I was researching ergonomic keyboards like The Corne and Ergodox Ez, I came across Logitech Wave Keys. To be honest, this keyboard wasn't my first choice. But because it was tenth the price of the other keyboards I was looking at, I had no other real choice. I bought it second-hand and waited.

When I first started typing, I was honestly quite surprised as it felt similar to my HHKB. It was really large and the keys were dome-like and low-profile.

This keyboard's main selling point is it's wave pattern across it's keys. It's suppose to help people who suffer from wrist pain and people who spend a lot of time in front of a desk.

To my surprise, it almost completely eliminated my wrist and hand pain. It also felt great to type on. It honestly saved me from spending a ton of money on a split keyboard that I would have to import and pay additional taxes on.

Conclusion

While some of these got replaced, they will always be tools that I cherish. I see them all as milestones that helped me in numerous ways.

Ironically, I wrote this post with my laptop's keyboard. This is the case for a lot of my posts as I like to write outside. I did not include my laptop's keyboard because it is trivial and isn't anything special. Also, being mindful of when I use my beloved tools makes using them more special.

Thanks a lot for reading. It has been a lengthy post that I really enjoyed writing. Feel free to email me if you want to share your writing tools or anything else. I love getting emails from humans!

-1:-- My Writing Tools (Post İsmail Efe Top (ismailefetop@gmail.com))--L0--C0--July 11, 2024 09:00 PM

Irreal: A N00b Reminisces

Over at the Emacs subreddit, Ok-Machine-6265 is a new(ish) Emacs user who has some thoughts after using Emacs for about a year and a half. His experience has been good. He loves the power that Emacs gives him and lists some of its many benefits:

  • Configurability
  • Visibility into all aspects of Emacs’ code and data
  • Keyboard centricity: no mouse required
  • Stability: core functions just work

and finally, Emacs is an editor for hackers and those who want to make it their own. You don’t have to customize it, of course, but if you need special operations, Emacs makes it possible and easy to add then.

As usual, a lot of the wisdom is in the comments. Ok-Machine-6265 had a few complaints:

  • Emacs can be slow to load large files
  • There are so many commands that it’s easy to forget their key bindings.

The commenters suggest many solutions to these problems. For example, the wonderful which-key goes a long way in helping you remember key sequences. It’s a third part app that I’ve been using for a long time but, happily, it will be builtin as of Emacs 30.

One of the things that Ok-Machine-6265 says is that Emacs is 100% configurable and one of the commenters objected to that saying that, for example, changing the behavior of Meta in Org mode is apt to break things. The commenters responded, and I agree, that 100% compatibility is not the same as easily reconfiguarable. It may be easy or it may be hard but at the end of the day, almost everything in Emacs is configurable.

-1:-- A N00b Reminisces (Post jcs)--L0--C0--July 11, 2024 04:05 PM

Irreal: Inlining The Previous Result In Edebug

Álvaro Ramírez has a very nice post about improving the edebug dislay. He starts be recalling the now nearly 10 year old post from Artur Malabarba on why you should learn to use edebug, the source level Elisp debugger. He says he uses it all the time when he wants to tweak some Emacs behavior.

Edebug will, among other things, let you step through a function and display the results of each expression to the minibuffer. That’s really handy but Ramírez finds it jarring to have to repeatedly move his eyes from the code buffer to the minibuffer. Being Ramírez, he decided to do something about it.

The TL;DR is that he advised the function that displays the value so that the result is displayed on the current line. You can see what that looks like from the animated GIFs on his post. It does seem like a much smoother result and I hope he submits a version upstream as a permanent change.

The big takeaway for me, though, is his account of how he tracked down the appropriate code to advise. If you want to tweak Emacs to do things your way, being able to find the code that needs tweaking is a prerequisite. You can learn a lot about how to do that from Ramírez’s post.

The post is definitely worth a few minutes of your time even if you don’t care about how edebug displays its results. It’s a great example of how it’s not that hard to track down the code that needs your attention.

-1:-- Inlining The Previous Result In Edebug (Post jcs)--L0--C0--July 10, 2024 03:34 PM

Kisaragi Hiu: Monthly review for June 2024

This month I spent 49 hours on translation, 15 of which are for KDE, and 17 hours on development. I left college, though not as a graduation due to personal failures. I guess I can just put it like that… Work I was contracted by MODA's zh_TW open source localization project to produce one set of translations for GIMP. Open source contributions [JS] Opened an issue for tc39/proposal-async-context pointing out there's a 404 link to an old Node blog post that had disappeared.
-1:-- Monthly review for June 2024 (Post Kisaragi Hiu)--L0--C0--July 10, 2024 02:43 AM

Irreal: Casual Ibuffer

Charles Choi is back with a new member of his Casual suite. His Casual suite, in case you don’t know, is a collection of transient based menus to make dealing with Emacs major modes and subsystems easier. Choi’s latest addition is for the ibuffer major mode. If you’re like me, you know exactly two commands for this. The first is to change to a named buffer (Ctrl+x b) and the second is to bring up a list of all the active buffers (Ctrl+x Ctrl+b).

Once you have the list of buffers (the ibuffer list), you’re probably aware that you can do some operations on it but, again if you’re like me, you know only a couple of them. One of the things I learned from Choi’s post is that are an astounding 132 commands available in the ibuffer listing. Who knew.

With that many commands, there’s virtually no chance of remembering them all. That’s where Casual Ibuffer comes in. As with the other Casual apps, it doesn’t try to cover every single command but provide easy access to those you’re most likely to use.

As I said, I always thought of the ibuffer list as simply a list and had no idea of all the hidden functionality hiding in it. Just reading through Choi’s announcement will show you how wrong that idea is. The real value, though, is opening our—or at least my—eyes to a whole new set of powerful commands for dealing with buffers, which are, after all, the fundamental Emacs construct.

-1:-- Casual Ibuffer (Post jcs)--L0--C0--July 09, 2024 05:11 PM

Andrea: I am keeping an up to date ob-http fork

I am keeping an up to date ob-http fork

Just a FYI: I decided to merge most of the proposed changes to the fantastic ob-http in the fork I am maintaining for myself.

If you want a fresher ob-http, just run:

(unless (package-installed-p 'vc-use-package)
    (package-vc-install "https://github.com/slotThe/vc-use-package"))

(use-package ob-http
  :vc (:repo ag91/ob-http :fetcher github))

I recently wanted to customize ob-http and seen that there has been no further development from years so far, I thought to update my fork.

I added also a way to upload a local file with a new :upload-file parameter to the source blocks:

#+BEGIN_SRC http :pretty :file :upload-file /tmp/my.txt
POST https://httpbin.org/anything
Content-Type: text/plain
Content-Disposition: attachment; filename="my.txt"
#+END_SRC

#+RESULTS:
#+begin_example
{
  "args": {},
  "data": "* Etiam vel tortor sodales tellus ultricies commodo.\n",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "*/*",
    "Content-Disposition": "attachment; filename=\"my.txt\"",
    "Content-Length": "53",
    "Content-Type": "text/plain",
    "Host": "httpbin.org",
    "User-Agent": "curl/7.81.0",
    "X-Amzn-Trace-Id": "Root=1-668db1b3-0e94aefe3fd0945f08d2f2fb"
  },
  "json": null,
  "method": "POST",
  "origin": "81.132.246.180",
  "url": "https://httpbin.org/anything"
}
#+end_example

Happy HTTP requesting!

-1:-- I am keeping an up to date ob-http fork (Post)--L0--C0--July 09, 2024 12:00 AM

Charles Choi: Announcing Casual IBuffer

One of the distinctive features of Emacs is its concept of buffers to organize work. In Emacs one doesn't directly access a file, but rather access a buffer that serves as an interface to that file. A buffer does not necessarily have a file associated with it.

It is commonplace for an Emacs user to see many (typically hundreds) of buffers open. This understandably introduces the need to manage so many buffers. This is what IBuffer aims to do.

What is IBuffer? To quote the GNU reference:

IBuffer is a major mode for viewing a list of buffers and operating on them in a way analogous to that of Dired including filtering, marking, sorting in various ways, and acting on buffers.

As of this writing, the IBuffer keymap has 132 commands. If one only resorts to using IBuffer's keybindings, this results in a very steep learning curve to use it effectively.

Casual IBuffer endeavors to address the above by overlaying a keyboard-driven menu system on IBuffer to organize and facilitate discovery of its commands. Casual IBuffer is now available on MELPA as part of the Casual Suite set of porcelains.

Using Casual IBuffer

Casual IBuffer organizes commands into three menus:

  1. The main menu (casual-ibuffer-tmenu) holding commands for marking and operating on buffers. Display, find/replace, and navigation commands are also included in this menu.
  2. The filter menu (casual-ibuffer-filter-tmenu) holding commands for defining filters, filter groups, and collections of filter groups.
  3. The sort menu (casual-ibuffer-sortby-tmenu) holding commands for sorting buffers.

Marking and Operating

Buffers can be marked using different criteria. Marked buffers can be operated on. Common operations include saving and deleting buffers. Note that deleting a buffer populated with a visited file is not the same as deleting the visited file.

From the main menu shown above, control of the display and find/replace operations are offered.

Note that the menu item Visit/Toggle has “do what I mean” (DWIM) behavior. If the point is currently on a filter group (described below) then pressing the return key will toggle the visibility of items matching that filter group. Otherwise, it will visit (open) the buffer.

As with other Casual porcelains, the ability to jump to a bookmark is available.

Filtering

IBuffer is embarrasingly rich in the ways it can filter buffers. Once mastered, IBuffer filtering offers a way to create different views on your buffer list, enabling you to tailor bespoke views for different workflows. Such capability though comes with a price: you'll need to understand how IBuffer wants to organize filters.

Key is the concept of a Filter Group which is IBuffer's analog to a Dired subdirectory (subdir). But whereas a subdir only maps to a file system directory, a filter group can be constructed from a diverse set of rules to categorize a buffer.

IBuffer organizes filtering with the following taxonomy:

  1. Filter rule

    The smallest unit of filtering. There are many types of filter rules which are enumerated below.

    • filter by major mode
    • filter by derived mode
    • filter by buffer name
    • filter by buffer content
    • filter by basename
    • filter by directory name
    • filter by filename
    • filter by file extension
    • filter by modified buffers
    • filter by an arbitrary Lisp predicate
    • filter by buffer size
    • filter by special buffers
    • filter by buffers visiting files

    Casual IBuffer makes the design decision to not enumerate the above in a menu, delegating the work of filter selection to the command ibuffer-filter-chosen-by-completion.

  2. Filter

    A filter is a logical combination of filter rules. Logic operators such as AND (&), OR (|) and NOT (!) are used to compose rules into a filter. A single filter rule can also be construed as a filter.

    Properties of filters:

    • A filter can be defined and saved for subsequent use.
      • Filters are saved in the customizable variable ibuffer-saved-filters.
      • Multiple filters can be applied at the same time to a set of buffers.
    • Multiple filters are applied in LIFO order. Removing a filter is a “pop” operation.
      • Rules that are combined with a logic operator are treated as a single element of the LIFO stack.
      • To individually edit the combination, use the Decompose command to remove the logic operator first.
  3. Filter Group

    A filter group is set of filters. The set itself is named with an identifier that is user-defined.

    Properties of filter groups:

    • A filter group can be defined and saved for subsequent use but with a special qualifier:
      • Filter groups are only saved as a collection (more below) in the customizable variable ibuffer-saved-filter-groups. A filter group can not be saved individually.
    • Multiple filter groups can be applied to partition the buffer list.
    • Multiple filter groups are applied in LIFO order. Removing a filter group is a “pop” operation.
      • Similar LIFO and decompose behavior applicable to a filter group is supported.
  4. Filter Group Collection

    A collection is a set of filter groups that can be named with a user-defined identifier. Only one collection can be applied to a buffer list at a time. However, many different collections can be defined, allowing for different views of the same buffer list.

Creating Filters

The basic procedure for making a filter that applies to the entire buffer list is as follows:

  1. From the Filter menu, create a filter via (SPC) Rule… and some desired combination of operators.
  2. Save the filter via (s) Save…. You will be prompted to provide a name for the filter. This filter will be saved in the variable ibuffer-saved-filters.
  3. To recall this filter at a subsequent time, use (r) Switch to… in the Add section of the Filter menu.

Creating a Collection of Filter Groups

Here is where the taxonomy becomes significant as the IBuffer command set unfortunately does not provide much observability on edit operations to filters.

  1. Create a filter as described above.
  2. In the Add section of the Filter menu, select (g) Create Filter Group… to convert the filter into a filter group. You will be prompted to name the filter group. This group name will be enclosed by square brackets [].
  3. Multiple filter groups can be created by repeating steps 1 and 2 above. Note that when constructing a filter group, the IBuffer window will not provide observability of existing filter groups on the buffer list.
  4. You can save the set of filter groups as a collection in the Collection section with the command (S) Save…. You will be prompted to name the collection. Note that only one collection can be used at a time in IBuffer.

Out of the box, it is best to think of the IBuffer commands for editing buffer filters as a kit of parts and an arguably incomplete one at that. The Casual IBuffer filter menu (casual-ibuffer-filter-tmenu) is my attempt to build a comprehensible filter editor UI from this kit. Whether it succeeds in being comprehensible is left to user feedback.

Sorting

The buffer list can be sorted using different criteria as shown in the screenshot above.

Sort ordering can be reversed via the Invert command.

Closing Thoughts

There is a lot of surface area to IBuffer's command set, which hopefully Casual IBuffer has made more tractable. While filter editing is currently serviceable, I think there is room for improvement which given cycles I'll try to revisit in the not too distant future. That said, I've found the utility of Casual IBuffer significant enough to publish it for general distribution. It has become core to my usage of Emacs and I suspect it will become that way for others too.

References

-1:-- Announcing Casual IBuffer (Post Charles Choi)--L0--C0--July 08, 2024 09:25 PM

Irreal: Is Emacs Bloated?

Icy-Repair8024 says he’s a new Emacs user who started using it believing that Emacs was a “lightweight” editor but upon discovering all its features now believes it’s bloated and wonders if he should give up on it. I have to admit that that’s the first time I’ve ever heard the claim that Emacs is a lightweight editor. You almost always hear the reverse. I suppose that compared to Electron-based editors you could argue that Emacs is comparatively lightweight but no one ever does.

It’s interesting to read the comments. Most of them

  1. Scoff at the idea that Emacs could be described as lightweight in any meaningful way, and
  2. Make the point that whatever bloat there is doesn’t matter because most features you don’t use aren’t loaded and don’t take up much space on the disk.

A bigger question, to my mind, is what, exactly, do we mean by bloated. Some of the comments make the point that Emacs is, in fact, more a Lisp Machine than an editor so of course it has a lot of features and the ability to easily add those features is one of its strengths. Its memory and disk storage footprints are modest by today’s standards so Emacs can’t reasonably be said to be a resource hog.

One of the commenters notes that Icy-Repair8024’s account history shows that he’s merely trolling. I don’t know if he is or not but if it was a troll, it didn’t work. There were no angry retorts or denunciations, just reasoned rebuttals that marshal the facts.

My takeaway is that of course Emacs isn’t lightweight in any way that matters and that we should stop obsessing about its so called bloat and instead embrace its many features whether or not we use any particular one.

-1:-- Is Emacs Bloated? (Post jcs)--L0--C0--July 08, 2024 03:45 PM

Sacha Chua: 2024-07-08 Emacs news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Mastodon #emacs, Hacker News, lobste.rs, programming.dev, lemmy, communick.news, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, and emacs-devel. Thanks to Andrés Ramírez for emacs-devel links. Do you have an Emacs-related link or announcement? Please e-mail me at sacha@sachachua.com. Thank you!

-1:-- 2024-07-08 Emacs news (Post Sacha Chua)--L0--C0--July 08, 2024 01:11 PM

Lars Ingebrigtsen: I Should Have Implemented The Emacs Inputs Correctly The First Time

Back when I wrote eww, the Emacs web er wrangler?, I was futzing around a lot with basic input box functionality. Like this:

And it basically kinda works, but it’s easy to break, even if you don’t really try.

But that’s a bigger problem in user interfaces like this, where you have all these boxes that can’t really grow in size, because that messes up the display. But you have to be able to enter longer texts, so…

So I cheat, and move the second column down if the box gets too big. Eh, whatchagonnado…

I briefly contemplated making a real “scrolling input box” — that is, if you type in too much, then the text at the left disappears from sight. That’s easy enough to do, but then commands like `M-DEL’ doesn’t work right, and you really want all those nice Emacs editing commands in input boxes.

Hm… It occurs to me while typing this that perhaps this wouldn’t be impossible by judicious use of invisible text props — that is, if we’re typing too much, then make the left bits invisible so that it looks like it’s scrolling? And then reveal it if moving the cursor to the left… Urrr…

But! I’ve fixed a whole bunch of other bugs in the input box things, and I’m thinking I should separate that out into a separate package, and then adapt eww to use that… Possibly?

If it ever gets to a glitch-free state, that is. It gets many things right now, but there’s a ton of corner cases. It’s really fighting against the Emacs display/editing machinery — this is in a read-only buffer, but with inhibit-read-only text properties in the editable fields, and that’s not really… er… well thought through. But I’ll try to keep poking at it and see what happens — I’ve already been through four different iterations of the algorithm (read the VC log and weep), and it’s just hard — Emacs kinda really rebels against altering the text too much from after-change-functions, so you can’t delete/reinsert the field, but have to pad things gingerly to avoid having point go awry…

I’m not sure this will ever actually “work”, as in “not have awful corner cases”.

Anyway. I’ve implemented autocomplete in eplot for colours, faces, files and the like.

I think this interface for doing adjustments to the chart is getting to be kinda usable, actually.

And I’ve implemented smoothed curves.

Kids, don’t try Bezier curves at home — you may end up with something like the above if you’re not careful.

JUST SAY NO!

As usual when I’m implementing something, I’m starting to notice how others actually do that thing I’m doing (so that I can steal I mean get inspired).

Here’s a chart from LanguageLog…

And here’s how `M-x eplot’ looks in the CSV buffer. (Yes, you can now plot directly from CSV buffers if you have the pcsv buffer installed.)

It’s kinda reasonable? Is the line-and-then-marker thing LanguageLog uses sensible? I think it looks a bit messy, but it does mark every “real” data point, which is nice… Hm.

Here’s the same data from PubMed itself. Notably, they include origo. Both of these pick nice Y scales, but I guess it’s a matter of taste whether to include origo.

This jazz chart reminded me that it should be possible to include formatting of the X and Y labels, so I added that:

And here’s a thing that’s usual in finance:

Plotting two different things with two different Y axes. I’ve never liked this style — the two things plotted here have different scales, and I just think it’s harder to make sense of. I suspect these charts became popular when you have to print a lot of charts on paper and wanted to save space, but that’s no longer usually a big concern (unless you’re publishing in a scienteriffic journal).

Also woth nothing here is that they chose pleasing max nunmbers (3 and 9) by extending the Y axes, and then they also did the same negatively… which looks nice and symmetric, but wastes a lot of resolution. And also — they chose horrible numbers between zero and max — 1.80, 3.60…!?

Anyway, I think eplot is getting close to actually being useful, so perhaps I’ll contemplate doing a release sometime soonish. But you can test it out via Microsoft Github. Please do open issues if there’s something wrong, or you have ideas, or interesting data sets that eplot gets wrong.

-1:-- I Should Have Implemented The Emacs Inputs Correctly The First Time (Post larsmagne23)--L0--C0--July 08, 2024 12:32 PM

Irreal: Moving To The Beg/End Of Structures

Over at the Emacs subreddit, justsellingmykeeb asks for the best way of moving to the beginning or end of various structures such as regions delimited by some sort of brace or HTML tag. I usually use Ctrl+Meta+f, Ctrl+Meta+b, and, when I remember, expand-region for this but those don’t always do exactly what I want.

There are a lot of good answers in the comments and they’re definitely worth reading if you have the same problem. These range from the simple like expand-region to the more complex like paredit. I like the simpler answers—even though I am a paredit user—because I’m terrible at remembering key shortcuts that I don’t use frequently. Maybe Charles Choi should consider a paredit porcelain.

Regardless of your proclivities, there’s probably a suggestion in the comments that will work for you. Take a look and see.

-1:-- Moving To The Beg/End Of Structures (Post jcs)--L0--C0--July 07, 2024 04:01 PM

Alex Popescu: Emacs OrgMode: Reports About Clocked Time

The other day I discovered, by mistake or better said by mistyping, the OrgMode org-clock-display function which is bound to C-c C-x C-d. What does org-clock-display do? It creates an overlay that displays clocked times for the entier buffer. Simply said: it does some accounting on clocked time and displays it without changing the underlying buffer. Once you are done, you remove the overlay using org-clock-remove-overlays. Looking for similar or related functions, I also found the OrgMode org-clock-report function which creates a table-based report for the clocked time.
-1:-- Emacs OrgMode: Reports About Clocked Time (Post)--L0--C0--July 07, 2024 12:35 PM

Irreal: Configuring A Private Ispell Dictionary

Chris Maiorana has a useful piece of information for all Emacs users. If you’ve used Emacs at all for writing you’re doubtlessly familiar with ispell. I’m a terrible speller and absolutely couldn’t live without it. I have it set up with flyspell so that my frequent typos/misspellings are highlighted in the buffer as I make them. All it takes is a single keystroke to correct—or at least suggest a list of corrections to—the error.

You can configure various dictionaries for use with ispell but whatever you choose you will inevitably encounter correctly spelled words that are not in the dictionary. Perhaps it’s your last name, the name of your blog, or a technical term; you’re going to have it pop up as an error every time you use it.

Maiorana tells us how to have a “private dictionary” to which we can add these outliers and have them accepted by ispell. It’s a small thing, I suppose, but it’s nice to be able to write without having a bunch of errors pop up.

It’s pretty easy to set up. All you need to do is specify a file to hold your outlaw words and then add your private words to it. That’s easily done as the errors pop up. A simple keystroke adds the unknown word to your private dictionary and you never have to worry about it again.

It’s a short post and well worth a couple of minutes of your time to read if you’re tired of having special words that you use all the time pop up as errors.

Update [2024-07-06 Sat 16:56]: Added link to Maiorana’s post.

-1:-- Configuring A Private Ispell Dictionary (Post jcs)--L0--C0--July 06, 2024 03:50 PM

Alex Popescu: Making Emacs Imenu More Visible, More Useful

Super useful hints from Charles Choi on how to make Emacs Imenu both more visible and implicitely more useful: My guidance is to turn on the index menu in the Emacs UI for modes that support it. The benefits to this are: One can always discover and access the index in the main menu. Even if one prefers a keyboard-driven workflow, recalling either the command (imenu) or some user-defined binding to it can be reinforced by visually seeing “Index” in the menu bar.
-1:-- Making Emacs Imenu More Visible, More Useful (Post)--L0--C0--July 05, 2024 07:11 PM

Irreal: Ready Player Mode

Álvaro Ramirez has announced another of his “ease my workflow” projects. Like many, or perhaps most, of the best projects, this one was conceived to scratch an author’s itch. This particular itch was finding a way of taking a quick look—or listen—to a media file from within Emacs.

It’s pretty easy to launch an external app to display or play a media file but Ramírez wanted to take his quick peek without leaving Emacs. He was inspired by image-mode and used it as a model for his solution. He liked being able to get out of the app quickly by simply pressing q and being able to navigate between media files in a directory easily with n and p. The actual playback is handled by one of mpv, vlc, ffplay, or mplayer according to the user’s configuration or by simply trying each of them in the order listed.

The application is brand new, has been tested only on macOS, and is not yet on Melpa but it is available from his from GitHub repository if it sounds like something you need right now. If it sound intriguing but not urgent you should probably wait a bit until he gets the wrinkles ironed out.

In any event, it’s one more way of staying in Emacs while still performing (non-editing) tasks on your computer.

-1:-- Ready Player Mode (Post jcs)--L0--C0--July 05, 2024 04:12 PM

James Dyer: WOWEE v0.3.3



More tinkering and enhancements to some AutoHotKey scripts with WOWEE to allow some emacs keybindings throughout the realm of Windows.

WOWEE is a set of AutoHotKey scripts designed to bring Emacs-like commands and keybindings to the Windows operating system. Based on the concept of EWOW (Emacs Way of Operating Windows), WOWEE allows you to use Emacs-style navigation and commands throughout your Windows environment.

I have this on github : https://github.com/captainflasmr/wowee

As I have been playing ergo for a little while with Emacs I decided to bring in some of this functionality, for example some common ergo keybindings.

Ergonomic keyboard layout options

Additional AHK files that can be run in parallel with the main wowee.ahk file if you would prefer some extra ergonomic mappings.

For example it is common to map the Caps Lock key to the Control key to avoid the dreaded Emacs pinky, which can be performed by running up :

wowee--caps_to_ctrl.ahk

I prefer to map the right hand Alt key to the Control key by running:

wowee--ralt_to_ctrl.ahk

Both can also be run if desired!

Whats New

Version 0.3.3 <2024-07-01 Mon>

A little support for Notepad++:

  • isearch
  • comment line

Version 0.3.2 <2024-07-01 Mon>

Separated individual ergonomic key-mappings as thus:

  • wowee–caps_to_ctrl.ahk
  • wowee–ralt_to_ctrl.ahk

These are extra files that can be run in addition to the main wowee.ahk for some common ergonomic keyboard Emacs mappings.

Version 0.3.1 <2024-06-30 Sun>

This commit has added windows, frames support

  • kill frame (C-x c)
  • split window vertically (C-x 3)
  • maximize window (C-x 1)
  • next window (C-x o)
  • suspend frame (C-z)
  • reorganisation of kanban
  • reorganisation of commands.ahk to better group

kanban

This kanban board is keeping track of those original EWOW functions.

The IGNORE column includes functions that I am definitely not going to implement.

The EXTRA section are additional commands that I am adding.

There is a prefix type indicator for each command referring to the specific type:

(C) - Core Emacs commands (VS) - Visual Studio specific (VC) - VSCode specific (N++) - NotePad++ specific (E) - Extra

and any command with an asterisk is an unconventional Emacs keybinding which will probably get fixed sometime in the future!

TODO DOING DONE IGNORE
(C) REGION COMMANDS (VS) VISUAL STUDIO (C) MOTION COMMANDS (C) JUMPING AROUND COMMANDS
- (C) mark_word - (VS) recenter_line (C-l) - (C) forward_char (C-f) - (C) scroll_left
- (C) yank_pop - (VS) indent_line (C-i) - (C) backward_char (C-b) - (C) scroll_right
- (C) kill_region (VC) VSCODE - (C) forward_word (M-f) (C) NEWLINE AND INDENT COMMANDS
- (C) delete_backward_char - (VC) isearch_backwards (C-r) - (C) backward_word (M-b) - (C) open_line
- (C) kill_word - (VC) isearch_forwards (C-s) - (C) next_line (C-n) (C) EDIT COMMANDS
- (C) kill_whole_line - (VC) comment_line (C-;) - (C) previous_line (C-p) - (C) transpose_chars
(C) NEWLINE AND INDENT COMMANDS - (VC) recenter_line (C-l) (C) JUMPING AROUND COMMANDS - (C) transpose_words
- (C) newline (N++) NOTEPAD++ - (C) scroll_down (C-v) - (C) transpose_lines
- (C) delete_indentation (E) PROGRAM SPECIFIC PRESETS - (C) scroll_up (M-v) (C) CASE CONVERSION COMMANDS
(C) EDIT COMMANDS (E) ERGO PRESET SELECTION - (C) move_beginning_of_line (C-a) - (C) upcase_region
- (C) redo - (C) move_end_of_line (C-e) - (C) downcase_region
- (C) query_replace - (C) beginning_of_buffer (M-<) - (C) upcase_word
- (C) overwrite_mode - (C) end_of_buffer (M->) - (C) downcase_word
- (E) isearch-yank-word-or-char - (C) goto_line (M-g g) - (C) capitalize_word
(C) INSERT PAIRS COMMANDS (C) REGION COMMANDS (C) MACRO RECORDING COMMANDS
- (C) insert_parentheses - (E) mark_whole_line (M-s ,) (C) ADD IGNORE FRAMES
- (C) insert_comment - (C) mark_whole_buffer (C-x h) (C) ADD MOUSE EVENTS
- (C) indent_new_comment_line - (C) kill_ring_save (M-w)
(C) OTHER COMMANDS - (C) yank (C-y)
- (C) shell - (C) delete_char (C-d)
- (C) shell_command - (C) backward_kill_word (M-BKSP)
- (C) facemenu - (C) kill_line (C-k)
- (C) help (C) NEWLINE AND INDENT COMMANDS
(C) SYSTEM COMMANDS - (C) indent_for_tab_command (C-i)
- (C) ignore (C) EDIT COMMANDS
- (C) repeat - (C) undo_only (C-/)
(C) UNIVERSAL ARGUMENT COMMANDS - (C) search_forward (C-s)
(C) FILES COMMANDS - (C) search_backward (C-r)
- (C) write_file (C) SYSTEM COMMANDS
- (C) find_file - (C) set_mark_command (C-SPC)
- (C) dired - (C) set_c-x_command (C-x)
(C) WINDOWS FRAMES COMMANDS - (C) keyboard_quit (C-g)
- (C) delete_window (C) FILES COMMANDS
- (C) split_window - (*C) save_buffer (C-x s)
- (C) previous_window (C) WINDOWS FRAMES COMMANDS
(C) ADD HOOKS - (*C) kill_frame (C-x c)
(C) ADD GENERIC GOTO LINE - (C) next_window (C-x o)
(C) ADD KILL RING - (C) suspend_frame (C-z)
(VC) VSCODE (C) ADD C-X (C-x)
- (VC) indent_line (C-i) (VS) VISUAL STUDIO
- (VS) isearch_backwards (C-r)
- (VS) isearch_forwards (C-s)
- (VS) comment_line (C-;)
- (VS) split window vert (C-x 3)
(N++) NOTEPAD++
- (N++) isearch_backwards (C-r)
- (N++) isearch_forwards (C-s)
- (N++) comment_line (C-;)
-1:-- WOWEE v0.3.3 (Post James Dyer)--L0--C0--July 05, 2024 06:58 AM

Irreal: Charles Choi on Imenu

Charles Choi has an excellent post on imenu. I’ve used it for a long time via the excellent councel-imenu but I’ve never really understood its scope or essential raison d’être. I’ve always thought of it as a way of locating functions and variables in a programming language buffer but that turns out to be a very circumscribed view of its purpose.

Choi has a much better explanation. He explains that what it really does is index many types of files that have some sort of definitions. This includes programming language files, of course, but also text files such as Org, Markdown, and other structured files.

You can get a feeling for how it works by trying it out on various types of files. It’s builtin so there’s no need to load it or do anything special to try it out. If you’re a swiper user, I recommend binding some easy binding to councel-imenu. I have it bound to Ctrl+. so it’s easy to invoke. Councel-imenu will bring up a completing read list of targets in the minibuffer that makes it easy to select the target.

Take a look at Choi’s post for other ways of using imenu. If you’re a menu user, you can easily add it to the menu. If, like me, you avoid the mouse, imenu is completely accessible through the keyboard. Choi recommends having it enabled by default but I find that having it an easy key shortcut away works well for me.

-1:-- Charles Choi on Imenu (Post jcs)--L0--C0--July 04, 2024 03:38 PM

Chris Maiorana: Emacs Micro Lesson 11: Personal ispell dictionary

Some people have a philosophical aversion to spell-checkers. And I can understand that. (Though, I find grammar checkers more fussy, prescriptive, and generally annoying.) As a general rule, I’d say avoid grammar checkers in creative writing, but they are OK for business writing. So there’s a happy medium between both philosophies.

Today, however, I’m just talking about a spell-checker in Emacs: ispell. This spell-checker comes pre-installed if you’re running Emacs on Linux. Mac users may require some additional configuration.

Apparently, I use a lot of uncommon words in my writing. (You see, I’m a writer.) So the default ispell dictionary will often flag me for a word I spelled correctly! So it’s far from perfect.

That’s why Emacs gives you a nice variable: ispell-personal-dictionary. This variable accepts a file as a value. That file contains a list of words you have added to your personal dictionary.

And you don’t need to edit the file manually. You can add words to your dictionary right from Emacs.

Set Up Your Dictionary File

Customize variable: ispell-personal-dictionary.

Or, for those who like to write configurations manually in Emacs Lisp, you can put this in your config file:

(setq ispell-personal-dictionary "~/path/to/your/personal-dictionary-file")

Adding Words To Your Personal Ispell Dictionary

If you spell a word correctly but ispell is flagging you, it’s easy to add the word to your personal dictionary. I’d recommend double-checking to make sure you have indeed spelled the word correctly, then you can

  1. C-c $ over the word at point
  2. Scroll through the corrections
  3. Go to the bottom, click Save word

That’s it! Open up your dictionary file, and you can confirm, your word is there.

-1:-- Emacs Micro Lesson 11: Personal ispell dictionary (Post chris)--L0--C0--July 04, 2024 01:47 PM

Alvaro Ramirez: Ready Player Mode

03 July 2024 Ready Player Mode

meme.gif

As an Emacs user, I eventually made the leap over to dired as my file manager of choice. Dired has magical things like wdired. But this post isn't so much about dired and more about the occasional need to peek at media files (images, audio, and video) from Emacs (including dired).

To view images in Emacs, there's image mode, a fantastic major mode for taking a quick look without leaving your editor. Image mode strikes a great balance. You can get in quickly and out. The q keyboard binding is fabulous for bailing out. While viewing an image, you may quickly open the previous/next one by using n and p keyboard binding. For me, this is just about all I need within my text editor. For anything else, I resort to my favorite image viewing app (macOS's Preview).

For audio and video, we aren't as lucky with Emacs built-in features (even for a quick peek). While Emacs faithfully opens the files, it's not realistically practical for my typical needs.

no-handling.png

There's a convenient package aptly named openwith, which automatically opens specific files in an external app. This isn't just for media files, but anything really. It works well with office docs, for example. While I've used it for quite some time, I found always bouncing to an external app for peeking at audio/video somewhat suboptimal.

While a reddit post yielded some handy options, none were in the same spirit as image mode. Having said that, I did come across mediainfo-mode on my search, which is pretty neat for viewing media metadata quickly. Bonus points for q keyboard binding to exit and mediainfo-mode-open command to open with an external app. There may be other packages out there (I'd love to hear about them), though most seemed to focus on listening to music (and playlist management), which is a different flow from what I'm after.

Ready player mode enters the chat

With all that, I had no choice (I kid of course) but to go and throw some lines of elisp together and see if I could get to my ideal media experience, and so ready player mode was born…

ready-player.png

video-player.png

As core features, ready-player-mode has two buttons: one to play from within Emacs and one to open media in the preferred external app. You can TAB your way to the buttons. RET or click actions the buttons, in addition to the SPC keyboard binding to toggle playback.

Like image mode, ready-player-mode offers n/p navigation to open the next/previous media file in the current directory.

ready-player-mode attempts to display basic metadata if possible, courtesy of ffprobe and ffmpeg. You'll need these installed on your system if you want the optional metadata.

Playback is handled by your favourite command line utility. ready-player-mode will try to use either mpv, vlc, ffplay, or mplayer (in that order), but you can customize that.

ready-player-mode is available on GitHub if you're keen to check it out. Keep in mind this is a brand new package (a day old!), so it may need some improvements. If you do give it a try, I'd love to hear how you got on. I've only tested on macOS so far.

Unrelated - Want your own blog?

Like this blog? Want to start a blog? Run your blog off a single file. Write from the comfort of Emacs and drag and drop to the web. I'm launching a blogging service at lmno.lol. Looking for early adopters. Get in touch.

-1:-- Ready Player Mode (Post)--L0--C0--July 03, 2024 05:20 PM

Irreal: Programming Fonts

Many, many years ago I adopted the Inconsolata font because it was one of the first widely available, free, antialiased programming fonts. In those days, I was still using Vim but when I moved to Emacs, I brought it along with me. From time-to-time I see recommendations for the “ultimate” programming font but I always stay with Inconsolata.

Once you’ve dealt with antialiasing, I think that the critical aspects of a programming font are:

  • Distinguishing between oh and zero in a visually obvious way
  • Distinguishing between el, eye, and one in a visually obvious way

It’s a bit shocking how many fonts get this wrong.

Over at Evil Martians there’s a nice post on what constitutes the perfect coding font. That includes my desiderata about 0, o, O, i, I, l, L, 1 but also considers additional characters than can cause confusion. The post recommends

  • Widening the various brackets types so they can be more easily distinguished
  • Making the hyphen and the minus signs the same
  • Making ^ and * resemble the corresponding mathematical symbols
  • Mathematical symbols, ticks, and quotes should not be too small
  • Slashes and bars should be centered

These are all useful criteria but I’m happy if I can distinguish zero and one from other characters. The comments over at reddit suggest all sorts of recommendations for the perfect programming font but, as I say, I’ve been happy with Inconsolata for a long time and probably won’t be changing.

-1:-- Programming Fonts (Post jcs)--L0--C0--July 03, 2024 04:30 PM

Protesilaos Stavrou: Emacs: consult-denote version 0.1.0

The consult-denote provides glue code to integrate denote with Daniel Mendler’s consult package. The idea is to enhance minibuffer interactions, such as by providing a preview of the file-to-linked/opened and by adding more sources to the consult-buffer command. Interested users can enable the consult-denote-mode to get started.

Familiar minibuffer prompts

consult-denote is designed to enhance all relevant Denote prompts with whatever extras Consult provides, such as the preview facility. These Consult-powered minibuffer prompts will still follow the same patterns of interaction as core Denote: they will never use a profoundly different presentation.

Customise what consult-buffer shows from Denote

The extra sources added to the consult-buffer command are controlled by the user option consult-denote-buffer-sources. Its default value is the list of sources called consult-denote-all-buffer-sources.

Developed in tandem with Denote

My goal with this package is to keep it as close to Denote as possible. If the community wants a new feature, we can discuss whether a variant of it makes sense for denote before considering its inclusion in consult-denote.

Sources

Consult-Denote

  • Package name (GNU ELPA): consult-denote
  • Official manual: not available yet.
  • Change log: not available yet.
  • Git repositories:
  • Backronym: Consult-Orchestrated Navigation and Selection of Unambiguous Targets…denote.

Denote

Denote is a simple note-taking tool for Emacs. It is based on the idea that notes should follow a predictable and descriptive file-naming scheme. The file name must offer a clear indication of what the note is about, without reference to any other metadata. Denote basically streamlines the creation of such files while providing facilities to link between them.

Denote’s file-naming scheme is not limited to “notes”. It can be used for all types of file, including those that are not editable in Emacs, such as videos. Naming files in a consistent way makes their filtering and retrieval considerably easier. Denote provides relevant facilities to rename files, regardless of file type.

-1:-- Emacs: consult-denote version 0.1.0 (Post)--L0--C0--July 03, 2024 12:00 AM

Charles Choi: TIL Imenu

Recently I learned that Imenu is a thing. While likely old-hat to those who already know, nevertheless this post will endeavor to 1) restate Imenu's profound usefulness, 2) argue that Imenu is terribly named, and 3) because of its terrible naming, argue that an index menu should be turned on by default in Emacs.

Imenu - what is it?

To quote the GNU reference for it:

The Imenu facility offers a way to find the major definitions in a file by name. It is also useful in text formatter major modes, where it treats each chapter, section, etc., as a definition.

For programming modes, Imenu gives you a menu interface (either mouse or keyboard-completion-driven) to the class/method/function and variable declarations in a file. It also provides the same analogous functionality for the headings in your Markdown files.

If the above hasn't sunk in, perhaps these screenshots will covey Imenu's utility. From the main menu, you can immediately go to a function declaration.

That same index menu is available via a right-mouse button click context menu.

Users who prefer a keyboard-driven UI can invoke the command M-x imenu where a completing-read interface is offered.

In short, in Emacs the common IDE feature of having your class/method/function/variable declarations in a menu is provided for by Imenu. Regrettably, this feature is not turned on by default in core Emacs.

Imenu is a terrible name

Some unvarnished opinion: I think Imenu is a terrible name. Abbreviating “i”, joining it with “menu”, and calling it a day has resulted in name so anodyne and milquetoast that it is easily forgettable. Also given the ambiguous semantics of an “i” prefix (I personally confuse it with the incremental in I-search) only adds to the high cognitive load of remembering Emacs commands and bindings. This is regrettable as an index menu is a common and arguably core feature in contemporary IDEs.

Turn on Imenu by default

Here’s the funny thing though. Most other IDEs don’t even bother to name an index menu feature as it is enabled (or rather, baked-in) in the UI by default. So I think it should be with Emacs. My guidance is to turn on the index menu in the Emacs UI for modes that support it. The benefits to this are:

  • One can always discover and access the index in the main menu.
  • Even if one prefers a keyboard-driven workflow, recalling either the command (imenu) or some user-defined binding to it can be reinforced by visually seeing "Index" in the menu bar.

Of course, the above guidance presumes that the menu bar is not configured to be hidden. Especially if you are new to Emacs, please do not disable the menu bar.

Imenu Configuration

To enable an index menu in the menu bar and context menu requires adding imenu-add-menubar-index to the hook of a mode that supports it. For example, the following configuration will enable an index menu for Markdown, Makefile, and all modes derived from the programming mode prog-mode.

1
2
3
(add-hook 'markdown-mode-hook #'imenu-add-menubar-index)
(add-hook 'makefile-mode-hook #'imenu-add-menubar-index)
(add-hook 'prog-mode-hook #'imenu-add-menubar-index)

Note that the above prog-mode-hook configuration presumes that the derived programming mode you use supports Imenu. As far as I know, this is true for most every popular programming language mode.

To turn on context menu mode, add context-menu-mode to the mode hook of interest. For example for prog-mode-hook:

1
(add-hook 'prog-mode-hook 'context-menu-mode)

By default, changes to the file will not automatically update the index menu. Set imenu-auto-rescan to t in local fashion as shown below:

1
2
3
4
5
6
(add-hook 'markdown-mode-hook (lambda () (setq-local imenu-auto-rescan t)))
(add-hook 'makefile-mode-hook (lambda () (setq-local imenu-auto-rescan t)))
(add-hook 'prog-mode-hook
      (lambda ()
        (setq-local imenu-auto-rescan t)
        (setq-local imenu-sort-function #'imenu--sort-by-name)))

The variable imenu-sort-function can be set to a function that will sort the index order. Imenu provides two sort functions: imenu--sort-by-name and imenu--sort-by-position, the latter being the default if imenu-sort-function is not set. In typical Emacs fashion, a user-defined function can be used for those motivated enough to reverse engineer the Imenu sort functions.

One might be concerned on the performance issues of auto-rescan and/or sorting a file index but in practice I've really not experienced any noticeable slowdown. I suggest turning them on, particularly auto-rescan as Imenu has contingencies to avoid rescan if the file size is too large (controlled by the variable imenu-auto-rescan-maxout) or takes too much time (controlled by the variable imenu-max-index-time).

What about Org Mode?

Amended 2024-06-02 13:30 PDT

To my knowledge, Org does not support Imenu, but offers the command org-goto which is effectively the equivalent command to imenu.

Org mode does have support for Imenu but it comes with a couple of qualifiers:

  • The depth of the headings indexed is controlled by a separate customizable variable org-imenu-depth.
  • The Org file must have a first-level heading at the start of the document.
    • Org files that only have headings that are depth 2 or greater will not be recognized by Imenu.
      • For this case, Org offers the command org-goto which is effectively the equivalent command to imenu.

Shown below is configuration code to turn on Imenu for Org.

1
2
3
(setq org-imenu-depth 7)
(add-hook 'org-mode-hook #'imenu-add-menubar-index)
(add-hook 'org-mode-hook (lambda () (setq-local imenu-auto-rescan t)))

Note: Thanks to Signal_Pattern_2063 on Reddit for commenting on my initial error of saying Org doesn't support Imenu. It does but with the caveats described above.

Casual Avy

Index navigation is so closely related the behavior of Casual Avy that I've added Imenu support to it as of v1.2.2.

Closing Thoughts

Imenu is a nice UI feature in Emacs that is too easy to ignore because it is not enabled by default. Leave it on always and be surprised at how useful it can be.

-1:-- TIL Imenu (Post Charles Choi)--L0--C0--July 02, 2024 06:40 PM

Irreal: EmacsConf 2024: Call For Participation

Planning for the 2024 EmacsConf is underway and the organizers are calling for participation. “Calling for participation” means they’re asking folks to submit proposals for talks. The conference will again be virtual and take place on December 7th and 8th.

If you’re interested in contributing, the organizers would like to hear from you as soon as possible but in any event by September 20. Your talk can be short (about 5–10 minutes) or long (about 20 minutes). If you’d like to give a longer talk, that can be arranged too: get in touch with the organizers.

EmacsConf is a great way to share your ideas and get some exposure. It’s virtual so there’s no expensive travel involved. Even if you are unavailable for questions on the day(s) of the conference, the organizers can accommodate that so if you think you have something to say, sign up for talk. The talks are prerecorded so you don’t have to worry about stage fright.

These conferences are a font of great ideas so whether or not you give a talk, be sure to be there. Even if you can’t be there, the talks will be available as recordings so you can enjoy them at your leisure but you won’t be able to join in the after talk discussions.

-1:-- EmacsConf 2024: Call For Participation (Post jcs)--L0--C0--July 02, 2024 04:29 PM

Lars Ingebrigtsen: Accidental Cover Design

-1:-- Accidental Cover Design (Post larsmagne23)--L0--C0--July 02, 2024 08:31 AM

Sacha Chua: 2024-07-01 Emacs news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Mastodon #emacs, Hacker News, lobste.rs, kbin, programming.dev, lemmy, communick.news, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar, and emacs-devel. Thanks to Andrés Ramírez for emacs-devel links. Do you have an Emacs-related link or announcement? Please e-mail me at sacha@sachachua.com. Thank you!

-1:-- 2024-07-01 Emacs news (Post Sacha Chua)--L0--C0--July 01, 2024 10:34 PM

James Cherti: Emacs: Customizing the Ellipsis (…) in Outline Mode and Outline Minor Mode

5/5

The built-in Emacs outline-mode and outline-minor-mode allow structuring documents with collapsible sections. By default, these modes use an ellipsis (“…”) to indicate folded text. However, the default ellipsis and its face can make it hard to distinguish between folded text and regular text. This is why it can be beneficial to customize the ellipsis.

The code snippets provided in this article allow for customizing the ellipsis either globally or locally within a buffer.

Set the global outline ellipsis

The following function can be used to change the ellipsis in both outline-mode and outline-minor-mode to ▼:

(defun my-outline-set-global-ellipsis (ellipsis)
  "Apply the ellipsis ELLIPSIS to outline mode globally."
  (let* ((face-offset (* (face-id 'shadow) (ash 1 22)))
         (value (vconcat (mapcar (lambda (c) (+ face-offset c)) ellipsis))))
    (set-display-table-slot standard-display-table 'selective-display value)))

(my-outline-set-global-ellipsis " ▼ ")

The Elisp code above will change the outline-mode and outline-minor-mode ellipsis to:

(The screenshot above shows a YAML file folded using outline-indent.el or outline-yaml.el, which leverages outline-minor-mode to outline and enable code folding in YAML files.)

Set the buffer local outline ellipsis

To apply the ellipsis locally to a buffer, the following Elisp code snippet modifies the display settings within that buffer. This ensures that any changes made affect only the current buffer, leaving the global Emacs environment unaffected. This approach is particularly useful for customizing displays in specific files or testing new configurations without affecting other buffers or sessions.

Here is the Emacs Lisp code snippet to achieve this:

(defun my-outline-set-buffer-local-ellipsis (ellipsis)
  "Apply the ellipsis ELLIPSIS to outline mode locally to a buffer."
  (let* ((display-table (or buffer-display-table (make-display-table)))
         (face-offset (* (face-id 'shadow) (ash 1 22)))
         (value (vconcat (mapcar (lambda (c) (+ face-offset c)) ellipsis))))
    (set-display-table-slot display-table 'selective-display value)
    (setq buffer-display-table display-table)))

And here is an example of applying the buffer-local ellipsis to text-mode:

(add-hook 'text-mode-hook
          #'(lambda() (my-outline-set-buffer-local-ellipsis " ▼ ")))

Conclusion

Customizing the ellipsis in outline-mode and outline-minor-mode is a simple yet effective way to personalize your Emacs and create a more visually appealing way to handle folds.

-1:-- Emacs: Customizing the Ellipsis (…) in Outline Mode and Outline Minor Mode (Post James Cherti)--L0--C0--July 01, 2024 08:10 PM

James Cherti: Emacs: YAML file code Folding and Outlining

5/5

Working with long and complex YAML files can be a daunting task. In such cases, code folding becomes an invaluable tool, allowing the collapse and expansion of sections of the file and enhancing readability and navigation. This makes it easier to focus on specific parts of the code without being overwhelmed by the entire document.

To address this need, I would like to introduce you to outline-yaml.el, a minor mode for Emacs that brings code folding and outlining capabilities to YAML files, making editing YAML files more efficient and enjoyable. Leveraging Emacs’ built-in outline-minor-mode, outline-yaml.el provides a structured and navigable view of YAML content, simplifying the editing of even the most difficult YAML files.

Installation of outline-yaml.el

  1. Install and configure yaml-mode or yaml-ts-mode.
  2. If you haven’t already done so, add the straight.el bootstrap code to your init file.
  3. After that, add the following code to your Emacs init file:
(use-package outline-yaml
  :ensure t
  :straight (outline-yaml
             :type git
             :host github
             :repo "jamescherti/outline-yaml.el")
  :hook
  ((yaml-mode . outline-yaml-minor-mode)
   (yaml-ts-mode . outline-yaml-minor-mode)))

How to change the Ellipsis (…) to (▼)?

The code snippet in this article can be used to to change the Ellipsis to ▼.

Links

-1:-- Emacs: YAML file code Folding and Outlining (Post James Cherti)--L0--C0--July 01, 2024 06:38 PM

Lars Ingebrigtsen: Further Emacs Interface Innovations

Yesteday I was musing about different input mechanisms for fiddling around with the look of charts. But then, while falling asleep, I thought “why not just put all the control in a buffer”, and so I did.

The result is on Microsoft Github, and it’s in a pretty rough state because I’m slightly busy today, but here’s a demonstration:

Eh? Eh? No, I don’t know either.

And now I’m off to wash the car.

-1:-- Further Emacs Interface Innovations (Post larsmagne23)--L0--C0--July 01, 2024 11:41 AM

Lars Ingebrigtsen: Emacs eplot UI vs UX

A few days ago I pushed a new library for making charts interactively in Emacs to Microsoft Github. One suggestion was to use transient or something to allow customising the look of the charts instead of adding headers to the data buffer.

Which makes a lot of sense — you don’t want to alter the data just to plot something. But on the other hand, I didn’t really know what it’d look like — for UX stuff, you really have to just try.

Behold! The most thrilling video in the history of videos! That are thrilling!

And… It’s got discoverability going for it, but it seemed to take kinda a long time? OK, let’s try the same with headers (this is an unrehearsed screen recording, but of course I know what the header names are, kinda sorta):

That took as long, really.

Anybody else got ideas here? More interactivity would be nice, and of course I could see resizing the chart with the mouse or something, but how do you express “raise the grid to the front of the chart and make it less opaque”?

Perhaps a double tap triple finger swirl counter clockwise. Yeah, that’s how Steve Jobs would have done it.

-1:-- Emacs eplot UI vs UX (Post larsmagne23)--L0--C0--June 30, 2024 10:06 PM

Irreal: Favorite Emacs Utilities

Over at the Emacs subreddit, Phovox—a 30-year Emacs user—asks what your favorite Emacs utilities are. He’s started using Doom Emacs and has discovered, through Doom, utilities that he didn’t know about. So he’s wondering what else he may have missed and is asking the community what they recommend.

Some of the answers were general things like the ability to use Emacs to change virtually any part of Emacs to suit your preferences. Others were more on point and included things like Dired, Hippie-expand, the classical version control system, Ediff, Magit, Calc, Org, Projectile, LSP, and Replace-regexp.

Some of the other commenters mentioned third-party packages such as Hyperbole and Everything.

The best advice, I think, came from Wumpitz. That is to spend some time with the Emacs manual. It’s too much to try to read it straight through, of course, but you can decide to read one chapter every day or week. It is, says Wumpitz, amazing how much you don’t know about some of the basic utilities.

All the action is in the comments so take a look to see if there’s some utility you should be using but aren’t.

-1:-- Favorite Emacs Utilities (Post jcs)--L0--C0--June 30, 2024 04:53 PM

Please note that planet.emacslife.com aggregates blogs, and blog authors might mention or link to nonfree things. To add a feed to this page, please e-mail the RSS or ATOM feed URL to sacha@sachachua.com . Thank you!