Skip to content

Smart Key Thing Selection

Hyperbole has some radically cool ways to select regions of structured text or source code and to copy or move them between buffers with a single mouse drag or two key presses. A great deal of smarts are built-in so that it does the right thing most of the time; many other attempts at similar behavior such as thingatpt.el fail to deal with many file format complexities.

We use the term things to refer to structured entities that Hyperbole can select. These include: delimited pairs of (), {}, <>, [] and quote marks, source code functions, source code comments and matching tag pairs in HTML and SGML modes. Delimited things are those things that contain a selectable delimiter such as an opening parenthesis.

The best way to mark a delimited thing is to move your cursor to the starting delimiter of the thing and then press the Action Key. Typically, you will see the thing highlight. You can then operate upon it as you would any Emacs region. In many cases, you can do the same thing upon the closing delimiter, but this is not as reliable. An Action Key press on the start of an HTML, XML, or SGML tag pair marks the entire region span of the pair. If you use the Assist Key instead, it will mark and kill (delete) the thing.

Even better are Smart Mouse Key thing drags which let you copy or move delimited things in one operation without having to select a region. To copy, simply drag with the Action Key from a thing’s opening delimiter and release somewhere outside of the thing, either within the same window or within another window. The thing will be copied to the point of release. If you want to move a thing, simply perform the same drag but with the Assist Mouse Key. Ensure that you do not move any explicit buttons from one buffer to another as that does not work.

Hyperbole also binds two convenience keys for working with things.

The first such key is {C-c RET} hui-select-thing which selects bigger and bigger syntactic regions with each successive use. Double or triple clicks of the Selection Key (left mouse key) do the same thing. The first press selects a region based upon the character at point. For example, with point over an opening or closing grouping character, such as { or }, the whole grouping is selected, e.g. a C function. When on an _ or - within a programming language identifier name, the whole name is selected. The type of selection is displayed in the minibuffer as feedback. When using a language in which indentation determines nesting level like Python, a double click on the first alpha character of a line, such as an if statement, selects the current clause (until the next line at the same or lesser indentation). Use {C-g} to unmark the region when done. Use, hui-select-thing-with-mouse if you want to bind this to a different mouse key to use single clicks instead of double clicks.

This key defers to any currently active major-mode which also binds it.

The second convenience key is bound in HTML/XML/SGML/web modes. {C-c .} hui-select-goto-matching-tag jumps between the opening and closing tag of a pair. It moves point to the start of the tag paired with the closest tag that point is within or which it precedes. A second press moves point to the matching tag of the pair, allowing you to quickly jump back and forth between opening and closing tags.

This key defers to any currently active major-mode which also binds it.