Category Archives: Emacs

Emacs ile ilgili her şey…

How to preview fixed width (mono spaced) fonts in an editable Emacs buffer?

When using Emacs, I don’t spend time thinking about fonts most of the time. Like the majority, I pick my favorite fixed width, mono space font and get on with it. Every now and then I can hear about some cool new font for reading lots of software source code and technical writing, and I might give it a try, but that’s the end of it.

But sometimes, you just want to have an overview and see everything summed up in a single place, preferably an Emacs buffer so you can also play with it and hack it. Of course, your GNU/Linux, macOS, or MS Windows will happily show you all the available fonts, and let you filter out fixed width ones suitable for programming. Emacs itself can also do something very similar. But as I said, why not have something according to your taste?

With a bit of Emacs Lisp, it seems not that difficult, at least on GNU/Linux:

The result of running compare-monospace-font-families can be seen in the following screenshot: Read the rest of this entry »

1 Comment

Posted by on May 9, 2019 in Emacs, General


Tags: ,

HOW-TO: Poor Man’s Quiz Scorer in Emacs Lisp

Sometimes it’s about small data.

Recently I’ve been studying a topic using a book, and at the end of each chapter there are quizzes of 20-25 questions. My method was to open a text buffer in Emacs, and vertically note down the question number, my answers, and after finishing this, go to the correct answer list, and mark correct answers with Y, and wrong ones with N:

Y 1- A,B,C
Y 2- C
N 3- D
N 4- C
Y 5- A
Y 6- B,C,D
Y 7- B

That was all fine, but I found myself counting the number of correct answers, and calculate my score in terms of percentage manually. I could of course quickly run the `M-x count-matches` (or `how-many`) to see how many correct / wrong answers I had, but doing this more than a few tests seemed to become tedious. Therefore, Emacs Lisp to the rescue!

With this simple Emacs Lisp function, assigned to F12 function key, I can now simply hit F12 and see my score percentage in Emacs:

“Your test score percentage: 71.42857142857143”

There are of course alternative methods to solve this straightforward problem, e.g. you can run some shell scripts on your Emacs (or VIM) buffer, or on a simple text file. But I like this solution being self-contained in Emacs, as well as the fact that it’ll continue to run as intended 30 years from now, in a newer Emacs version probably. This, and the fact that, my preferred tool for dealing with textual data gives me the flexibility to program it any way I want. It might have its drawbacks, it might be showing its age in its architecture, there are newer, shiny tools, there are specialized IDEs for various programming languages I use, but all of these notwithstanding, I still like to think it’s a beautiful thing that an editor released when I was born, that helped me with many tasks for decades, will still be with me for decades to come.

Leave a comment

Posted by on February 26, 2017 in Emacs, Programlama


Tags: ,

Turkish Mode for Emacs is now available as a package via MELPA

Turkish Mode for Emacs, developed by Deniz Yüret, is now available as a package via MELPA. This is for people trying to type Turkish documents on a U.S. keyboard using Emacs. The program provides a `turkish-mode` in which the correct Turkish accents are added to the ASCII version of the last word typed each time the user hits space. If you are using a recent stable version of Emacs that lets you use the Emacs package manager, and you’ve added MELPA as a repository, installing it is as easy as running:

M-x package-install turkish

and then putting the following line in your init file:

(require 'turkish)

Once you have done that, in any Emacs session you can toggle the Turkish mode

M-x turkish-mode

The same program has been converted to many different languages and available on many platforms such as a Python package, a Java package, a Perl CPAN package, an Ubuntu PPA package, a web application,  a Chrome plug-in, a Firefox add-on, and a Safari add-on.

Leave a comment

Posted by on March 29, 2016 in Emacs, Programlama



How to edit remote files within Emacs when a program automatically runs after you SSH

If you are used to TRAMP functionality of Emacs to edit remote files without leaving the comfort of your beloved editor on your host machine, you do your best to keep it working even when different conditions arise. In my case, I’ve been recently working with virtual machines at work and the product that I’m working on is configured to run some program automatically right after I log into the machine via SSH. This prevents TRAMP functioning correctly with its default settings, because instead of receiving the shell prompt immediately, it receives from the machine the final line of the program that automatically runs and expects the user enter some response:

    ... some text menu options ...
    Please make a selection >>

Above that line, the text menu says that the user should enter 0 to exit the program or some other menu option to continue. Therefore, I had to find a way to tell Emacs that it had to send a 0 after it connects to the machine. The high-quality TRAMP manual was immediately helpful by providing a relevant example and I came up with the following: Read the rest of this entry »


Posted by on November 30, 2015 in Emacs, Lisp, Programlama


Tags: , , ,

How to detect Friday the 13th with full moon using Emacs

nrAlmost 21 years ago, in 1994, I bought the brand new edition of Numerical Recipes in C: The Art of Scientific Computing. As an engineering and mathematics student who was much into programming, I still remember my excitement then, as well as the bright red hard-cover.

The first algorithm presented in the book (and its implementation in C programming language) was about calculating the dates that were Friday the 13th and had full moon. Now that I’m approaching the 21st anniversary of that day, I wanted to share a similar program to detect if the current date is Friday the 13th with full moon. This time, my preference is for Emacs Lisp, and instead of re-implementing the same algorithm, I simply use the calculations already provided by Emacs. In other words, I rely on the lunar-phase-list function that returns the lunar phases of the upcoming dates given a month and a year.

It’s been ages since I’ve done Common Lisp programming and many years since I’ve practiced Emacs Lisp, so the code below is probably not optimal and idiomatic, but nevertheless it follows:

You can used the function defined above to see whether it is your “unlucky” day:

This will return “Good luck!” most of the time, luckily! 🙂

Can you come up with other ways of detecting Friday the 13th with full moon using existing utilities, such as GNU calendar program? Or, how would you calculate the next 10 Friday the 13ths that had full moon, using Emacs Lisp or some existing utility?


1 Comment

Posted by on November 12, 2015 in Emacs, Lisp, Programlama


Tags: , ,

Is this the State of the Art for grammar checking on Linux in 21st century?

Recently, I’ve shared an article with a colleague of mine. The article had been published in a peer-reviewed journal and the contents were original and interesting. On the other hand, my colleague, being a meticulous reader of scientific texts, has immediately spotted a few simple grammar errors. It was very easy to blame the authors and editors for not correcting such errors before publication, but this triggered another question:

Why don’t we have open source and very high quality grammar checking software that is already integrated into major text editors such as VIM, Emacs, etc.?

Any user of recent version of MS Word is well aware of on-the-fly grammar checking, at least for English. But as many academicians know very well, many of them use LaTeX to typeset their articles and rely on either well-known text editors such as VIM and Emacs, or specialized software for handling LaTeX easily. Therefore, to tell these people “go and check your article using MS Word, or copy paste your article text to an online grammar checking service” does not make a lot of sense. Those methods are not convenient and thus not very usable by hundreds of thousands of scientists writing articles every day. But what would be the ideal way? The answer is simple in theory: We have high quality open source spell checkers, at least for English, and they have been already integrated into major text editors, therefore scientists who write in LaTeX have no excuse for spelling errors, it is simply a matter of activating the spell checker. If only they had similar software for grammar checking, it would be very straightforward and convenient to eliminate the easiest grammar errors, at least for English.

A quick search on the Internet revealed the following for grammar checking on GNU/Linux:

– Baoqiu Cui has implemented a grammar checker integration for Emacs using link-grammar, but unfortunately it is far from easily usable.


Read the rest of this entry »

1 Comment

Posted by on June 10, 2014 in Emacs, Linguistics, Linux


Tags: , , , ,

Lean Text Editing with Emacs: Kanban Applied to the Process of Text Editing

The reader of this blog entry’s title might be ready for a long article, but sometimes the best things in life are very short and simple. Such as this subtle question and discovery of an Emacs user: Why don’t we eliminate waste of time by simply automating the white-space insertion after comma and most of the other punctuation characters?

Why, indeed? I’ve never thought of it before, yet, without giving it a single thought I’ve tortured my SPACE key millions of times. The solution? Simpy apply the following recipe to your beloved Emacs text editor, thereby adapting it to the Agile, Lean, and Kanban world of text editing by eliminating waste:

Read the rest of this entry »


Posted by on April 7, 2013 in Emacs, Programlama


Tags: , , , , , , ,

How to subtract a number from the current word and replace the result (in Emacs Lisp)

I needed to do some Emacs Lisp hacking for a little project (there are more conventional methods but they don’t have the sheer pleasure of hacking Lisp ;-)). Basically I wanted to come up with a function that takes the current word, converts it into an integer, subtracts some number from it, converts the resulting number into a string again and then replaces the original “word” with the new value:

Leave a comment

Posted by on December 20, 2011 in Emacs, Lisp, Programlama


Tags: , ,

Mouse Gestures Recognition in Emacs

I just realized that Emacs has mouse gesture recognition and it is called strokes-mode. I enabled it simply by M-x strokes-mode and then by invoking M-x strokes-global-set-stroke I created a very simple mouse gesture (by pressing left mouse button and dragging leftwards it along a more or less straight line) and then after pressing the right mouse button (that is the rightmost mouse button with scroll moused, mouse 3 in Emacs terminology) assigned the kill-buffer function to the mouse gesture. After that I pressed Shift and then dragged the mouse while pressing the middle button and saw that it correctly interpreted the gesture by invoking kill-buffer function.

Mouse gestures in Emacs

Mouse gestures in Emacs

Immediate help about gesture recognition is available via M-x strokes-help. You can learn more about the internals of gesture recognition in Emacs simply by reading the source code at

Not that I’d prefer using mouse gestures for simple commands but nevertheless I was surprised to discover yet another feature of Emacs which helps its fame of being called “… has everything but the kitchen sink” 😉

1 Comment

Posted by on November 22, 2010 in Emacs, Programlama


turkish-mode for Emacs (by Deniz Yüret)

Do you need to write in Turkish? Do you have a keyboard that does not have Turkish letters such as ş, ğ, İ, ı? Do you use the most powerful editor in the world? Then you’ll be happy to know the turkish-mode developed by Deniz Yüret:

This is for people trying to type Turkish documents on a U.S. keyboard using Emacs. The program provides a turkish-mode in which the correct Turkish accents are added to the ASCII version of the last word typed each time the user hits space. The latest version is available here.

That practically means as you type something like

“Bakalim duzgun yazabiliyor muyuz. Sanirim duzgun yazabiliyoruz, degil mi?”

Emacs converts it on-the-fly to this:

“Bakalım düzgün yazabiliyor muyuz? Sanırım düzgün yazabiliyoruz, değil mi?”.

I have also created a Git repo of turkish-mode at GitHub for my development purposes. Adding features to this wonderful system and then maybe re-implementing it as Firefox plug-in (with Jetpack maybe) would be of great utility.


Posted by on February 18, 2010 in Emacs, Linguistics, Programlama