Posts

Just In Time Lazy-Loading

In personal computing, there are multiple scenarios where Just in time (JIT) lazy-loading is desirable since what can be shown to the user at any point of time is limited by the screen real estate. This involves two steps: Detect changes Refresh the visible changed part during idle time Consequently, a framework to support these scenarios is desirable. Specific logic related to refreshing, like image loading or font coloring, can be encapsulated in individual functions which will be called by the framework. Detect Changes While editing a document, the number of changes will be huge. So it's better to track the extent of changes or the changed region instead of individual changes. When the file is loaded, the whole file is considered to be changed. Refresh the changed part in idle time Run a timer which kicks off when the computer is idle i.e. the user is not interacting with the computer. This is to ensure that the user never faces a lag in his interaction. If an idle timer is not

GNU Emacs as a Comic Book Reader

Image
  Comics are available in digital format as a collection of images in a compressed ZIP or RAR file (.cbz or .cbr file extension respectively). These can be enjoyed in GNU Emacs with full access to image viewing capabilities using keybindings.   # Make sure you have unrar installed for CBR files # apt install unrar   (require 'arc2-mode)   (setq archive-summarize-files-fn 'archive-summarize-files-as-thumb)     Note: The archive-mode is capable of displaying the list of files in an archive; though it depends on external tools for extraction. For JPG and PNG, Emacs can resize the image without external convertor (ie. imagemagick). However, some menu options for image transformations in image-mode might not be available. Use the following patch for image-mode.el . @@ -460,16 +460,16 @@ image-mode-map       :help "Show image as hex"]      "--"      ["Fit to Window Height" image-transform-fit-to-height -     :visible (eq image-type 'imagemagick) +

GNU Emacs as a Shopping App

Image
  How do you find the best price for items while shopping online? You can go to each website and compare yourself manually. Or let Emacs do the hard work for you!! You can start with a shopping list in a normal buffer. shop-mode minor mode allows you to search, compare and add products to your cart across multiple providers (presently Bigbasket and Jiomart ). You can finish the payment on the provider's website.   Keybindings s     Search the item o     Order the results by price, unit price, brand etc. q     Quit Unit price comparison allows better deals   Config (require 'shop)   ;; For webp image support (setq image-converter 'imagemagick)    Code https://github.com/atamariya/tumblesocks/blob/dev/shop.el

Stream ListenBrainz.org Music Playlist in GNU Emacs

Image
    Here's an Emacs Multimedia System (EMMS) extension for streaming ListenBrainz.org music playlist using mpv player (with ytdl support). Irrespective of how satisfied you are with your music streaming service, you should plan for maintaining a playlist of your favorite music in an open format. The popular service might be forced to close down because of non-profitability even when you are willing to pay for ad-free music streaming. e.g. Worldspace radio customers even paid for the device in addition to the subscription fees. The code uses following function from tumblesocks codebase. In case you don't use tumblesocks, you'll need to define it yourself. (defun tumblesocks-api-process-response (&optional service)   "Process Tumblr's response in the current buffer, returning JSON or signaling an error for other requests."   (decode-coding-region (point-min) (point-max) 'utf-8-dos)   ;; the following copied from url.el   (goto-char (point-min))   (sk

Zen Emacs: First Look

Image
  Zen is a minimal Emacs ( pl. Emacsen ) with multi-thread support . It is a fork of Zepl . (Edit 3/9/23: Zen Emacs is a better name compared to Zep). Demo The video demonstrates: Split window Indirect/cloned buffer - same content but different points (cursor) Asynchronous shell command (top) execution and view update Parallel editing while the command runs in the other window   Components Zepl - Editor backend tinylisp - Lisp interpreter ncurses - Terminal UI Code https://gitlab.com/atamariya/tinylisp (dev branch)  

Tinylisp and Multi-threaded Emacs

Image
TAME-ing the beast!! Here's a fork of tinylisp and a glimpse of a possible multi-threaded future. Below is the content of the file a.el in the demo. It creates one read thread which waits for non-nil value of global-var and a set thread which sleeps for 5s before modifying global-var and notifying the waiting threads. Since these are running in separate threads, main loop is free for user input. (define list (lambda args args)) (define defun (macro (f v . x) (list 'define f (list 'lambda v (cons 'progn x))))) (setq make-condition-variable make-cond) (setq condition-wait cond-wait) (setq condition-notify cond-signal) (setq message p) (setq sleep-for sleep) (setq global-var nil) ;; Create a mutex and an associated condition variable (setq mutex (make-mutex "mutex")) (setq cond-var (make-condition-variable mutex "cond-var")) ;; Read and set functions used by read and set threads (defun set-global-var ()   (mutex-lock mutex)   (sleep 5)   (setq global-

GNU Emacs as a lightweight IDE - Assembly

Image
CEDET support for Assembly language Auto-completion using company and speedbar outline view Jump to label Jump to include file Auto-completion using company Speedbar outline view     ASM file extensions supported - .s, .S and .asm   Grammar file: https://gitlab.com/atamariya/emacs/-/blob/dev/admin/grammars/asm.wy