Posts

Annotate completion candidates (GNU Emacs)

Image
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     

Text along a path (GNU Emacs)

Image
  SVG 2 specifications allows flowing text along a curve via textPath element. This opens up possibilities for cool text effects e.g. Formula Editor in GNU Emacs . GNU Emacs uses librsvg for SVG rendering on GNU/Linux. This fix for librsvg was  available in 2014 [4]. But this wasn't applied for some reason. Librsvg has moved to Rust since then. The code below is pre-Rust version of librsvg. sample.svg <?xml version="1.0" encoding="UTF-8"?> <svg height="300" width="800" xmlns="http://www.w3.org/2000/svg"      xmlns:xlink="http://www.w3.org/1999/xlink">     <path id="my_path1" d="M 50 100 Q 25 10 180 100 T 350 100 T 520 100 T 690 100" fill="transparent" />     <text>         <textPath xlink:href ="#my_path1" font-size="34"> Text along a path looks awesome!!         </textPath>     </text> </svg>   Text wrapping Text wrapping us

Context Menu is Personal (GNU Emacs)

Image
  Define custom menu based on your preferences. Note the definition of visibility conditions ( :visible keyword) and sub-menu ( More ). They are helpful in reducing the clutter. (Note: There are some placeholders in the code below.) (easy-menu-define my-menu global-map "My context menu"   '("Context Menu"     ["Cut"   kill-region :visible (region-active-p)]     ;; ["Copy"  kill-ring-save t] ;; Menu copies by default for further action     ["Paste" yank :visible (not (region-active-p))]     ["Open    " org-open-at-point t]     ["Calculate    " calc-grab-region t]     ["Execute    " (lambda () (interactive)             (shell-command-on-region (region-beginning) (region-end) "sh")) t]     ["Search Web" (lambda () (interactive) (eww (car kill-ring))) t]     ["Email    " yank t]     ["Print    " ps-print-region-with-faces t]     "--"     ["Define    &q

Alternatives in GNU Emacs - Wheel of time

Image
   Imagine you have a collection of images. Sometimes you want to view them in chronological order. However, chances are these pictures are not taken uniformly over a period of time. In other words, certain periods have more pictures than others. What kind of view can give you - A complete picture of the whole timeline for which pictures are available Time periods when you have more pictures than others An easy way to drill down into any period of interest This is wheel of time view in graph-brain . Since this is just a view and not a rigid directory structure, it allows additional conveniences. e.g. if you only have a single picture in a particular year, clicking on the year will take you directly to the picture. You don't have to navigate through month and day. Git Log Goes Spiral Git log display is mostly sequential including the branch commits. Color-coding the branches in a spiral seems handy.     Lessons Learnt On Linux, you can change the modification time of a file to an ol

Alternatives in GNU Emacs - Tag Explorer

Image
    Firefox provides the option to add tags to your bookmarks for categorization. These tags are available at this URL. chrome://browser/content/places/places.xhtml   If you want to access the same from GNU Emacs, you should backup as JSON to preserve tag information ( Import and Backup > Backup... ). The command graph-firefox-bookmarks parses this information and presents a graphical view. The command org-open-at-point opens the link in the browser. Code https://github.com/atamariya/tumblesocks/blob/dev/graph-pack.el https://github.com/atamariya/tumblesocks/blob/dev/graph-enclose.el https://github.com/atamariya/tumblesocks/blob/dev/graph-draw.el https://github.com/atamariya/tumblesocks/blob/dev/graph-brain.el    

Alternatives in GNU Emacs - File Explorer

Image
Traditionally, Operating Systems (OS) have had folders as an organization entity for collection of files. Documents, Videos, Photos and Downloads folders cover most of the use-cases. However, if you have used it for some length of time, you'll realize it is not enough. For instance, this blog post is a collection of text, images, videos and web URLs. And while working on this idea, I need all of these at my disposal. Or atleast an easy way to access all these related resources. That's when it clicked to me why some people are gung-ho about org-mode ! Often, it's better to organize files around ideas rather than file types. For a beginner, org-mode might seem daunting. I myself ignored it completely till few days back. Don't worry about learning the syntax in depth. Even if you are not using the advanced features, there's lot to be gained. Here's complete list of types of links you can store in a text file and access it using (org-open-at-point) . ( No

Analyzing 3 Body Problem in GNU Emacs

Image
Node view (left) and Group view (right)     3 Body Problem is a sci-fi series on Netflix. Though this post is more about the analyzing process in GNU Emacs than about the show storyline. This is a work-in-progress . The entry point to the package is M-x graph-brain . Design Decisions Leaf title will be displayed at the center of the circle. If it has an image, it will be displayed at the bottom. Group title is displayed at the top. Information gets fuzzier at a certain density. Around 16 leaves and three levels - root, groups and leaves - seems to be a comfortable threshold. org-roam is being used for the database. Presently, only ID, title, filetags and  link fields are being used. IMAGE is managed as an org-mode property.   The Shape We don't want to restrict the number of characters in the story. Yet we don't want to manually decide their placement on the screen. So we need a shape which can be easily placed based on geometrical calculations. The two simplest options are a