Emacs Lisp Functions
Emacs Lisp functions as presented here are conceptual initiative for readers to learn and get ideas to program themselves.
Excellent piece of programming language is the GNU Emacs editor itself. Yes, it is not just another editor. It is a true programming language that may do much for your life and business.
It may be used for plethora of real world applications. I am myself using GNU Emacs mostly for communication. Writing emails is one application of GNU Emacs. But did you know that it may be used to send SMS, to send faxes, prepare letters, prepare business contracts, to prepare reports of all kinds, to obtain your geographical location by reading data from the mobile phone, to follow up on your business cycles, to remind your clients on unpaid invoices, to provide accounting tools and reports...
And it can even manage your windows clean...
Emacs Lisp: Optimize JPG images within Dired with help of ImageMagick
This Emacs Lisp function is optimizing marked JPG images within Dired and GNU Emacs editor. It is using ImageMagick and web recommendation on how images shall be optimized. The quality of images will be 70% of the original and setttings for optimization are made for Internet. Do not use this function on images which quality shall remain intact for printing or publishing purposes others but web.
Emacs Lisp: ffmpeg-cut-dired
This function is used with Dired within Emacs to cut video files from specific begin time for specific duration. Files are cut and saved in the directory. This may be handy to use your Emacs editor as movie editor application.
Emacs Lisp: calculate interest rates on accrued HYIP investments
HYIP is High Yield Investment Program, a kind of a fraudulent scheme. We are not promoting such scheme rather dis-advising people who get caught by the greed and possibility to earn high income within few days. Sometimes the "yield" may be as much as 5% per week and more. And people investing into the HYIP or High Yield Investment Programs believe the nonsense. This Emacs Lisp function can demonstrate what money could the company earn would they be collecting money themselves, without asking public to receive more and more investments. Calculate yourself and compare it logically, and you will come to conclusion that a company offering that high interest rates would never ask public for new investments, they could be earning it themselves without sharing with anybody.
Emacs Lisp: 𝕸𝖆𝖙𝖍𝖊𝖒𝖆𝖙𝖎𝖈𝖆𝖑 𝕴𝖓𝖕𝖚𝖙 𝕸𝖊𝖙𝖍𝖔𝖉
This is 𝖒𝖆𝖙𝖍𝖊𝖒𝖆𝖙𝖎𝖈𝖆𝖑 𝖎𝖓𝖕𝖚𝖙 𝖒𝖊𝖙𝖍𝖔𝖉 for 𝕲𝕹𝖀 𝕰𝖒𝖆𝖈𝖘. If you wish to write with 𝖙𝖍𝖆𝖙 𝖙𝖞𝖕𝖊 𝖔𝖋 𝖑𝖊𝖙𝖙𝖊𝖗𝖘, 𝖞𝖔𝖚 𝖏𝖚𝖘𝖙 𝖑𝖔𝖆𝖉 𝖙𝖍𝖎𝖘 𝖋𝖎𝖑𝖊.
Emacs Lisp: input method for ⒸⒾⓇⒸⓁⒺⒹ letters
This enables easy writing of ⒸⒾⓇⒸⓁⒺⒹ letters with GNU Emacs text editor.
Emacs Lisp: input method for ＦＵＬＬＷＩＤＴＨ ＬＡＴＩＮ ＬＥＴＴＥＲＳ
This is input method for ＦＵＬＬＷＩＤＴＨ ＬＡＴＩＮ ＬＥＴＴＥＲＳ for easy writing whenever necessary.
Emacs Lisp: Azбukцeдa or azbukceda is a new mixture of cyrillic and latin alphabet as used in Bosnia and Herzegovina.
Azбukцeдa or azbukceda is a new mixture of cyrillic and latin alphabet as used in Bosnia and Herzegovina. It is mixture that is readable by every citizen of the country. Instead of using two alphabets the members of the society Eko Kultura speak and write in one united alphabet named azbukceda. This is new Emacs Lisp input method to write Azбukцeдa.
Emacs Lisp: The iota function for number ranges in Emacs Lisp
This is the iota function that I had to make today. I have shamelessly borrowed the description from Guile reference manual on iota function from SRFI-1 and tried to make it compliant. I guess this could be done more elegantly. For me is important that it gives me the same result as intended.
Emacs Lisp: why is programming language Emacs Lisp so comfortable?
My thoughts about the programming language Emacs Lisp. Apparently and initially designed to extend the GNU Emacs Editor, Emacs Lisp has grown into fully fledged programming language. Things like CGI, database interfaces, contact management, customer relationship management, project management, and so many other features becamse possible within GNU Emacs. Here is the summary on what I think what makes GNU Emacs and Emacs Lisp so comfortable programming language.
Emacs Lisp: Record screen within GNU Emacs
The program third party program
recordmydesktopis used for this function to invoke screen recording within GNU Emacs. You may wish to make a demonstration in video and publish such online. Record it while using few keybindings or
M-x record-screen. This page is giving you the concept of a workflow. I consider workflow more important then the function itself. You please modify it to suit your own needs. The
screen-record-commandis spitting out the actual screen recording command, customize it as you wish.
Emacs Lisp: Record voice notes within GNU Emacs
Sometimes you have no time to write and maybe you are talking or maybe you simply wish to record a voice note. Maybe you wish to send a voice message to somebody by email. Just use the
record-voice-notefunction and it will invoke the shell command
recfrom SOX sound tools system package. Yes, you must have it or this will not work. It will record a sound note and open it in Dired. Press
qto finish recording the sound.
Emacs Lisp: Send Status to your GNU Social instance via XMPP or Jabber protocol
This is simple customization that helps the user to send status to GNU Social instance by using XMPP protocol. It means you could get notices over messenger from GNU Social and you could send notices over any XMPP or Jabber messenger to GNU Social instance. You are getting connected wherever you are. XMPP is much easier to use then web browser. The username
firstname.lastname@example.org your GNU social instance virtual friend. That is something you set up in your GNU Social profile under IM menu. Requirement is that administrator has enabled the menu and XMPP plugin for the GNU Social instance. As of now 2019-08-07 I just guess there are not so many GNU Social instances with XMPP connection. And then you need to have your own XMPP username or Jabber ID. Such need not be on GNU Social instance, it can be anywhere you wish, on any server, if you already have it, you can use your own Jabber ID to send status updates to GNU Social instance and vice versa, you can also receive messages over GNU Social instance. Change it to suit you. It is just a simplification of the
jabber-send-messagefunction in the Emacs Lisp package
jabber.el. Great one! Coordinate with your team members, assign tasks directly from GNU Emacs to their messengers. Possibilities are wide to help in communication and coordination in any team. Otherwise have fun with decentralized GNU Social networks!
Emacs Lisp: avoiding repetition in writing Nginx web server configurations
Imagine you are handling hundreds of domains, and each time you need to write pretty similar web server configuration for each new domain. GNU Emacs is extensible text editor and operating environment that helps you to speed up your editing. Nginx is a web server with pretty complex configuration syntax. Yet directives for each doman may be similar to each other. By adapting these functions to your own needs you may get some speed in preparation of Nginx configuration.
Emacs Lisp: dig-txt and dig-txt-short as small extensions
Extending the GNU Emacs built-in
digfunction is very easy with
C-h fand function name and then inspecting how to make your extension. In this case
digis looking for text records which may be suitable to inspect SPF and other related DNS records.
Emacs Lisp: duden-lookup opens up https://www.duden.de German dictionary to lookup definitions
This example demonstrates how easy it is to advise your GNU Emacs to query the word on any website. In this case it is https://www.duden.de/ German dictionary. To find a definition of a German word in German language, place your cursor on the word and run
M-x duden-lookup. Adapt the function for your needs to open up any other website in similar fashion straight from Emacs.
Emacs Lisp: opening media files straight from GNU Emacs Dired mode by using xdg-open
This is my personal GNU Emacs Dired setup on the V key that helps me to quickly open media files or external viewers by using xdg-open and EMMS the Emacs Multimedia System.
Emacs Lisp: mark HTML on the web page and convert it quickly to Markdown format
Emacs Lisp: mark HTML on the web page and convert it quickly to Markdown format. This function needs your own customizations. You would mark the HTML on a web page within your browser. Then you run the Emacs Lisp function and the clipboard is converted into Markdown file. The file is opened for further editing and saved for future just as a note.
Emacs Lisp: take a screenshot withing GNU Emacs and
maimis small shell utility that takes screenshots, and with the option
-sit allows cropping of a screenshot. This makes it handy to bind the
screenshotfunction. After taking screenshot, Emacs is to open the Dired buffer with list of screenshots. From there you may send them by email or do whatever you want. If you are giving it the universal argument
C-uit will crop the rectangle on the screen.
Emacs Lisp: switch-to-scratch and return back to previous buffer
This function is using register 100 to
switch-to-scratchand remembers where to return back. Global key binding is Hyper key and 8 and once in the
*scratch*buffer, the local key binding is to return back to previous buffer.
Emacs Lisp: using mutt within GNU Emacs under ansi-term
This function requires some modifications for your own usage. As small script has to be setup to run the mutt directly with the
ansi-termfunction. The script named
emacs-mutt.shis executed under ansi-term emulation within GNU Emacs. Editor is set to emacsclient so that all editing takes place within the GNU Emacs. Configuration files without special colors are chosen.
Emacs Lisp: Common Lisp solution to accept Org files from standard input and emit markdown output
This was my previous Common Lisp solution, using CLISP implementation, to accept the Org files on standard input and emit markdown export from Org files. This is still working well, but the new solution by using GNU Emacs directly is more elegant.
Emacs Lisp: emacs-org-to-html.el on command line, convert your Org files on command line to HTML output
This is one way of converting the Org files on command line to HTML output. This is script that shall be made executable with chmod +x and it runs on command line. It may be used in website revision systems to feed Org input and get the HTML output. It could redirect to HTML file quickly, without launching full GNU Emacs. You may see inside that one function is to output full HTML and other only the body of the HTML. This is for those people who need to use templates.
Emacs Lisp: quickly insert Openstreetmap location link
This function asks the user for location, opens the Openstreetmap and inserts the link into buffer. Imagine you wish to tell your friends where you are located, so you need to give them some pointers.
Emacs Lisp: quickly remove menu items from GNU Emacs menus
This shows how one can quickly remove some items from GNU Emacs menus
Emacs Lisp: stockpile.el calculates volumes of stockpiles, heaps, piles, mounds
This set of function is calculating stockpile volumes depending of sizes of piles, mounds, or heaps. Engineers may be able to dissect various parts of stockpiles and then calculate their volumes by using these functions.
Emacs Lisp: mkdatedir works in Dired and quickly creates directory by date
Sorting files is one of tedious jobs we all do on the computer. Sorting is often best done chronologically by dates. Thus function creates directory within GNU Emacs Lisp, usually within Dired listings. Sort files by groups, people, and dates.
Emacs Lisp: produce speech by using espeak shell command
Espeak shell command is often faster then using Festival Speech. This function may be used to quickly produce some speach. Global variables such as
*espeak-voice*can help you set it up for your own language and volume.
Emacs Lisp: Get ATTENTION in those emails by using heading-underlined function
Sometimes you wish to really put attention in emails to certain facts or paragraphs of text. Using the heading-underlined function you quickly get upcased heading underlined that your reader cannot miss it!
Emacs Lisp: strip-html by Sacha Chua, remove those tags!
Sacha Chua is wonderful woman that likes GNU Emacs, notes, she has her thoughts well organized and lives a happy life. Once I had to find the strip-html function and it was just there, on her website, thank you Sacha!
Emacs Lisp: join-lines function
When there is need to join the lines, this handy function helps me in editing those formatted and wrapped lines into one single joined line.
Emacs Lisp: string-to-file-force function writes string to file forcefully
I often need to write strings to file, and without looking if the file exists or not, this handy function is doing exactly that.
Emacs Lisp: file-to-list function reads file line by line into a list
This Emacs Lisp function reads file line by line and returns list of lines. This may be handy when lines of the file need to be processed.
Emacs Lisp: read-from-buffer versus read-from-minibuffer, returns string from editing
As I am often editing database fields, and such fields could represent Org Mode or Markdown documents, this function is handy to quickly edit the string and return it back. It has no version control, thus I must take care what I am doing and how I am editing the string. As if something is lost, is lost forever. Unlike the read-from-minibuffer function, this one will open full editing buffer. If I switch the mode I have to use C-M-c option to return back.
Emacs Lisp: use speech on your computer by using festival.el and Festival Speech system
Festival already has its GNU Emacs Support, just install festival package in your GNU/Linux distribution and you will gain soon functions to output speech. Yes, instead of messages in your Emacs minibuffer, now you can hear the real speech and in several languages. Emacs could thus remind you of new emails or new messages coming and it could tell you about finished tasks or commands. Sounds nice?
Emacs Lisp: quick publishing of Emacs Lisp function to Internet
This is new Emacs Lisp function invented on 2019-07-15 that I am using to publish Emacs Lisp functions to Internet on my gnu.support website. It may not mean much to you as you are not using the PostgreSQL database for WRS or Website Revision System. If you do have a website, you could adapt this function to your own needs and quickly publish functions to Internet without thinking. Forget about those third party websites, just host yourself web pages.
Emacs Lisp: how to read file into a string?
GNU Emacs is the extensible, customizable, self-documenting real-time display editor with full programming language Emacs Lisp. This function file-to-string will show you how to quickly read file.
Kill to signature
This is one of mostly used functions on my side. Quoting emails and deleting the text not necessary is something I repeat so many times per day. This one have been stolen from function message-kill-to-signature and adapted from my needs. I do not use only message mode for writing emails. And it is bound globally to s-0 or hyperkey and zero.
(defun kill-to-signature (arg) "Kill all text up to the signature that begins with -- ." (interactive "P") ;; (rcd/emacs-lisp-log "email") (save-excursion (save-restriction (let ((point (point))) (narrow-to-region point (point-max)) (push-mark) (goto-char (point-min)) (if (re-search-forward "^-- $" nil t) (forward-line 1) (goto-char (point-max))) (unless (eobp) (if (and arg (numberp arg)) (forward-line (- -1 arg)) (end-of-line -1))) (unless (= point (point)) (kill-region point (point)) (unless (bolp) (insert "\n"))))))) (global-set-key (kbd "s-0") 'kill-to-signature)
Contact GNU.Support now. There is a simple rule at GNU.Support: if we can help you, we do, whenever and wherever necessary, and it's the way we've been doing business since 2002, and the only way we know