Category: linux

Insert Unique Log Message

I had tried to implement a debugging logging/print method myself using macros but hadn’t really achieved the level of elegance outlined in https://xenodium.com/sprinkle-me-logs/ I added a couple of programming modes to the function defined in the post above and have now incorporated it into my workflow: ((equal major-mode 'ada-mode) (cons (format "Ada.Text_Io.Put_Line (\"%s: \\([0-9]+\\)\");" word) (format "Ada.Text_Io.Put_Line (\"%s: %%s\");" word))) ((equal major-mode 'c++-mode) (cons (format "std::cout << \"%s: \\([0-9]+\\)\" << std::endl;" word) (format "std::cout << \"%s: %%s\" << std::endl;" word))) For some reason I always seem to tend to ribald statements within my code, something like poop or some other unsavoury variant, I just need to remember to tidy these up later on! Read more...

Initial focus in Occur Buffer

Just a quick one today! I am finding occur extremely useful, from building an index from my emacs init file to searching through org headers to generally just having my isearch all there in a single window. However I would rather the cursor would jump to the *Occur* buffer when invoked as it just feels a little more natural, so I added the following: (advice-add 'isearch-occur :after '(lambda (origin &rest args) (isearch-exit) (select-window (get-buffer-window "*Occur*")) (goto-char (point-min)) )) Read more...

Cursor Blinking Rate

Sometimes I can find a blinking cursor distracting and somewhat expectant!, so currently I am favouring a solid non blinking cursor while still being able to easily locate my cursor using hl-line-mode I have tried beacon and pulsar in the past but have found that a simple line highlight nicely serves my purpose. This however led to a weird issue at work with my emacs setup and although I am not quite sure why it is happening (although I have my theories) I have found a workaround. Read more...

Imenu Indexing My emacs Init File

After implementing my simple occur indexing in my last post : Indexing My Emacs Init File A suggestion was made to put this into an imenu. I thought that was rather a good idea and it would also give me the opportunity to explore imenu I came up with the following to add to the emacs init file : (add-hook 'emacs-lisp-mode-hook (lambda () (setq imenu-sort-function 'imenu--sort-by-name) (setq imenu-generic-expression '( (nil "^;;[[:space:]]+-> \\(. Read more...

Indexing My Emacs Init File

Since I keep all my emacs configuration in a single .emacs file and in a hyper organised manner it means I have my init file split into different sections, for example : platform packages mail calendar completion save-desktop keys modes setqs with each section delimited by a comment of the form: ;; ;; -> platform` ;; Now I am using occur more often, then why not write a function to produce a nice little Occur buffer containing an index of my init file sections, as thus: Read more...

Sorting Org Tags using Org Mode!

Well as always a little more time with emacs a little feedback and then finding more about org I have now figured out (I think) how I can better sort tags in an org file. In my previous post: Sorting Org Tags I made the following comment: I had assumed that org-mode came with the built-in ability to sort tags but I couldn’t find any evidence of this Well as it turns out there is evidence of this! Read more...

Sorting Org Tags

I use a package called org-rainbow-tags which adds random colours to org tags to provide a consistent colour between identical tags. This helps to identify common tags throughout the file but has the side effect of emphasising the lack of my coherent tag ordering. I would like to order the tags consistently, just for my own peace of mind! 😀 I had assumed tkhat org-mode came with the built-in ability to sort tags but I couldn’t find any evidence of this so I decided to create a method using my own function. Read more...

Trimming ArtRage Playback Scripts using Emacs

Emacs isn’t my only obsession, I like to create digital art and for that I use ArtRage. The interesting thing about ArtRage is that each brush stroke or editing action can be recorded in a text file or script for later playback. I use this facility for creating time-lapses. The ArtRage manual describes the following: Script Files ArtRage scripts are simple Unicode UTF16 text files which can be edited using Notepad, Notepad+++, TextEdit, or any similar program Read more...

Editing org files on an Android device - Part 1

Now that there is a build for emacs on Android I thought I would try and develop an emacs workflow between my Galaxy Note 8 / Galaxy Tab S7+ and my linux laptop. At the moment I am using Markor on my phone and this serves my needs adequately but of course I am missing that org file support. My current process involves syncthing to push my org files around my laptop / phone and tablet. Read more...

Replacing deadgrep with consult-ripgrep

I have been evolving my way through many differing ways of grepping recently from standard built-in greps to a few ripgrep front ends until I finally settled on deadgrep I am currently an ivy user but as everyone seems to be talking about vertico and the associated completion stack I thought I would give it a try and therefore consult-ripgrep to see it can improve on my deadgrep setup. Read more...

Digital Art Printing

Once a digital piece of art has been created then it is time to print it. A few tweaks are required in my image editor of choice and that is GIMP. Import the image into GIMP and perform the following to tweak the image so the printed image is as close to the digital image as possible: exposure : 1.3 brightness-contrast : 10 saturation : 1.24 and now to print, here are the typical setting that will work: Read more...

Using Macros to Help Code Debugging

Often I find myself requiring the most rudimentary of methods of debugging and that is to push text to standard output from within a running executable to indicate the logical structure of a program. This situation may come about if I can’t debug a dll or generally actually stopping a program to debug creates an “observer effect” Sometimes the logical structure can be somewhat complex consisting of a plethora of if statements and nested for loops, e. Read more...

Moving Away From Deft

As the title says, it is with a heavy heart that I have decided to move away from deft. There are a few reasons for this: All files I am interested in quickly locating and editing are now orgified (turned into org files) All these files are located in a single directory All these files have a sensible naming convention indicating the contents I am now much more familiar with dired I didn’t ever use the deft facility for creating new files, I prefer to use dired I didn’t ever need to incrementally filter / search as I can use emacs / dired for this Deft took a couple of seconds to initially load My deft configuration was becoming a little bloated and I wanted to use vanilla emacs where I could; see below for my former deft configuration: (use-package deft :bind ("C-c d" . Read more...

Commenting Un-commenting

After watching an interesting video by EmacsElements regarding commenting and un-commenting I have to say that I wholeheartedly agree. I really don’t like the way comment-dwim works and made me think back to one of the first elisp functions I commandeered from the interwebs : (defun my/comment-or-uncomment () "Comments or uncomments the current line or region." (interactive) (if (region-active-p) (comment-or-uncomment-region (region-beginning)(region-end)) (comment-or-uncomment-region (line-beginning-position)(line-end-position)))) and it is a command that I constantly use and had forgotten that it isn’t part of the emacs default functionality from a M-; Read more...

Simple Flexible Scrolling

I have written before about smooth scrolling using good-scroll and how I managed to find a semi satisfactory way of centering my cursor after a single scroll which meant I would then have a minimal amount of subsequent line movement to get to the line I want. However, I have since returned to a simple concept, more of a basic scroll-[up/down]-command which in its bare form scrolls a whole page. Read more...

How to Display Google Calendar

Emacs is subsuming me! I have managed to get email up and running using mu4e and rss using elfeed and image viewing with image-dired Next up is some form of calendar integration! Although I use Google Calendar I don’t rely on any google apps directly; an android app called Simple Calendar is adequate for my needs and enables the thing I cherish most of all (except emacs of course!) and that is the ability to produce an offline copy. Read more...

Using ripgrep within Projects

Given my recent forays into the world of grepping in emacs using deadgrep (and hence ripgrep) and my use of find-file-rg which feeds into my current completion system of ivy I think the next step is to try to set up a project and to see if I can gain any advantages in my workflow. I am not yet going to dive head first into projectile but dangle a tentative pinky into the deep project pools of the built in project system, namely EDE (Emacs Development Environment). Read more...

More flexible grepping with deadgrep

I seem to be grepping a lot recently and I think the way I use deadgrep can be improved a little. Currently deadgrep defaults to a recursive ripgrep from the default-directory which is generally the current directory of the buffer, but I find that by default I tend to mostly want to grep from a top level directory (yes I know, almost like a project!). I would like to have a typical Find All References type of functionality from my grepping and not to rely on xref as I will not necessarily ever know if any xref functionality is supported for any file that I am working on and for the moment I am not using any connection to an LSP server. Read more...

Using org-copy-visible in dired

Just a quick one. Often it seems I need a copy of a list of files / directories in plain text without any gubbins such as a path, permissions, date and all those shenanigans, basically basenaming; for example: So how can I achieve this in emacs? I would really prefer to use dired somehow rather than shell / ls (which was my first thought) Below is my typical dired listing: Read more...

Creating Album Art Thumbnails for EMMS

I have been looking for a music player on Linux for a while now but haven’t really settled on one; I have simple requirements: A view showing album art An easy way to play random tracks A quick method to skip a track To date I have only been considering players with a graphical front end but it always seems a hassle to, open the program, look for some music, figure out how the shuffle and play work; and then what if I don’t like the current track playing? Read more...

Dired Duplicate Here

dired can do most things for me especially now I have my DWIM image conversion scripts working and image-dired configured to my liking. However sometimes I do just prefer using a GUI file manager; for example, drag and drop, image file preview e.t.c. I am currently using the Dolphin file manager on KDE and one context menu service that I have enabled and use often is the Duplicate Here function. Read more...

Merging org files for Hugo static site

I have just started the process of reducing the number of org files I maintain for my web site. I now have a greater understanding of how Hugo handles these files and I think can both simplify and make them more flexible. Hugo is my static site generator of choice and although it supports org files directly I prefer to generate to a markdown file as an intermediate step using a file by file evaluation of org-hugo-auto-export-mode. Read more...

Creating a DVD from a video file

This year I have been starting to archive anything of interest from the family VHS collection. There are certainly slim pickings and it is difficult to find anything when most of the 200+ videos contains either a western or a Dire Straits concert! But I did find a film that my mum loves and she really doesn’t want to lose, so what better way than to burn a captured video file to DVD and what better way than to use free and open software on linux to achieve this. Read more...

Quick Bash Scripts Augmenting Org Files

This post isn’t strictly about what can be achieved within the emacs ecosystem but what can be achieved outside it while still binding to the workflow principles of org mode. I have yet to convert to any of the internal shells/terminal emulators within emacs, I have continued to Control-Alt-T (C-M-t) term my way around linux; although this is becoming less frequent due to my greater proficiency with dired As my org journey evolves I have now realised that I have two files I rely on for my quick capturing needs. Read more...

RIP ripgrep-regexp, long live deadgrep!

Well this is quite a turn up for the books, I seem to have already quickly moved on from emacs ripgrep-regexp! to something better and that is a package called deadgrep Now why is this? I hear you all ask, your new grepping workflow seemed perfect, a process of file searching that could last the ages. Well as it turns out that age was more of a collection of weeks. Read more...

RIP grep, long live ripgrep!

I have come to the realisation that I can be a little more efficient when it comes to searching for text within files, or as it is known in software engineering circles, grepping! I am often looking for a string within a collection of files and mainly for a Find All References type of functionality. Typically I would want to accept a string (could be regex) and a directory and the search to descend through all sub directories. Read more...

Expanding Text using abbrev and skeletons

My next investigation into trying to improve my emacs workflow is expanding entered text for repetitive tasks. I’m not yet sure how useful this will be for me as I typically copy and paste my way through the creation of text files, especially org files. Maybe org-capture could be a help? As always I want to try built in options to augment my vanilla emacs setup, so the obvious place to look is abbrev. Read more...

Revisiting Window Cut / Copy Files with DWIM

I previously wrote about wanting the ability in emacs to copy and paste files from one window to another just like a linux GUI file manager and after a little hunting around and experimentation I settled on putting together some elisp: Cut / Copy Files from Window to Window using Dired Buffers This worked pretty well for a while although there were a couple of side effects that I hadn’t bargained for! Read more...

Dired ordering by size

By default dired orders its files in alphanumeric order and when s is selected it sorts by date according to : (dired-sort-toggle-or-edit &optional ARG) But recently I wanted to list files according to their size, which of course is a very common thing to do especially when you are undertaking a nice spring clean up. The solution is to modify the dired-listing-switches to add in an S argument which can be found by passing in the universal argument to s, hence : C-u s Read more...

Tidying up Dired Further

Something is still bugging me with my dired tidy up and I think it is wanting to add the ability to remove dot files. I am currently using the Dolphin file manager on linux and by default I tend not to show the dot files for a cleaner output, generally the only dot file of course I really care about are the emacs ones and I know where they are! Read more...

Tidying up Dired

Bit by bit I am getting to grips with dired and using this for more operations on my files. The next step is to reduce the listing width so that a listing fits better in a smaller window. Here is the format of my current listing: By default dired uses -al, which gives a standard long listing. Unfortunately for my work within emacs this is actually now too long, and also not just in emacs but in my terminal too. Read more...

Centering the Cursor After a Scroll

Something has been nagging at me for a while now, I seem to spend a lot of time moving the cursor to the next or previous line within a window, spamming C-n and C-p to get where I want to within a file. Why is this? Well I am scrolling quite often using C-v and M-v and this has a side effect on the cursor by pushing it to the top or bottom of the window. Read more...

Do You Remember?

I am currently keeping all my textual notes in a separate org file called appropriately, notes.org. This is pretty much just a random rambling set of text containing bits and bobs that I don’t want to forget. If I am mobile and want to jot something down I use an android app called Markor, just open up the notes.org as a text file and add something in. Syncthing means that this file is present on my laptop when I open it up in emacs. Read more...

Dired folder size

My dired replacement of Dolphin / linux terminal continues. The next thing is something useful to me but uncommon and something that dired didn’t seem to be able to do out of the box. That is to be able to recursively display the size of a folder / files. Every now and again I like to keep my files and data under control especially as I am using syncthing to backup my core data to my phone. Read more...

Dired going Up Directories

Now dired is becoming more ingrained into my muscle memory, navigating efficiently through the folder structure is becoming more prominent in my mind and it still doesn’t feel natural enough. I now don’t even think about using C-x d and the Enter key is fine for either opening a file or traversing into a directory. But what about moving up a directory!, also a very common action. The default defined key is ^ and actually isn’t too bad and almost feels quite natural, almost… Read more...

Cut / Copy between Windows using Dired Buffers

The next step in my emacs journey is to move files around a little more easily, in fact more like a regular file explorer using the concept of file / folder selection copy and paste. That concept seems a little more natural to me than dired file marking, renaming / copying and then entering the path of the destination address. After a little research the following options present themselves: Read more...

Trimming Text With Macros

I am having a bet!, it is one of my few vices, and it shall be on the horses. I don’t often have a bet and in fact I generally only ever have a bet on a special occasion, like the grand national or a random parallel bet with my dad. Today is a parallel bet, yesterday my dad won over £650 and I have decided to leverage his expert equine knowledge to have a little flutter. Read more...

Finding Files With RipGrep

Now I am appreciating the power and simplicity of ripgrep and have it available on all my systems I was hunting around emacs to see the best way to leverage this tool for quick file searching. Working on a code base that is familiar to me is fine when locating files within emacs as of course I know where to go and when I am not I would typically open up a terminal and use find Read more...

Putting to Trash

I was recently reading a post about deleting files from within emacs and pushing them to the local Trash, this seems like a good idea especially now I am using dired more often. After using describe-function and typing trash there was a single completion, namely move-file-to-trash from this I figured out I should add the following my .emacs: (setq trash-directory "~/.local/share/Trash/files") (setq delete-by-moving-to-trash t) I am running this on OpenSuse so the location of the Trash folder may vary from system to system. Read more...

Efficient Deletion and Insertion

As my emacs keybindings journey continues to evolve and to delete more efficiently with delete word it has lead to an interesting issue for me. Typically, especially in my coding life I will typically copy a string to the clipboard, then go in and delete the target area and insert from the clipboard/kill-ring. Now I have moved from deleting with the delete key to the the M-delete-word concept it seems that deleting words automatically puts this to the clipboard/kill-ring, so when I paste in my original copy it pastes back in the last killed words. Read more...

Hugo Text Title Tidying

Currently I am just displaying the title of my posts with no filtering. Now that I have developed a general format to help with some emacs Deft categorisation I have run into a little bit of a problem. For example a typical title format is the following: Linux ---> Hugo_Format_Title[tag@subtag-art] and the hugo rendered html of course displays this on a card list and on a single page. I would like to remove the Linux ---> part and the tag part to optimise the space taken up by the title. Read more...

Hugo No Carriage Return After Frame

I am currently polishing up my web page and I am now focussing on the little annoying formatting / alignment issues. One of these is involving a default shortcode called {< youtube >} (Note: I deliberately missed off second brace as I am writing this in org!) Anyways, I have the following markdown: {< youtube IDK-4lhQ-sE >} A gradual fading version of a portrait I did for my girlfriends parents. Using ArtRage and Infinite Painter on various drawing tablets which produces the following displayed html: Read more...

Images to Blog Posts

I am just playing around with writing some sort of “techy” blog, trying to focus on a couple of my favourite things in the world, namely linux and emacs, so I thought I would do the best productive thing in the world and just start to type. I have set up this blog in a certain way using a static web site generator called Hugo, but more on that later down the road. Read more...

Profiling and Accidental Learning

My sacred emacs is taking 13 seconds to start up! This is not good, I have read somewhere about a built in profiler, and indeed when I ivy complete for a function profiler I find a plethora of options. profiler-start looks good, and with a little intersearching it all seems simple enough, except it looks as though it probably won’t solve my start up problems but will profile any commands I execute in emacs, so would solve for example an issue I had in the past with deft starting up. Read more...

Download Local Emacs Packages

— TOC Local ELPA MELPA ORG Local from Mirror Extra Steps to locally download emacs packages for offline installation. Local ELPA MELPA ORG cd ~ mkdir -p emacs-pkgs/melpa mkdir -p emacs-pkgs/elpa # mirror the melpa emacs archive echo echo "updating MELPA..." echo rsync -avz --delete --progress rsync://melpa.org/packages/ ~/emacs-pkgs/melpa/. # elpa echo echo "updating ELPA..." echo rsync -avz --delete --progress elpa.gnu.org::elpa/. ~/emacs-pkgs/elpa # org (currently no rsync support) echo echo "updating ORG. Read more...