1

Running emacs 25.2.2 on Kubuntu 17.10.

I have an Org mode file that is mostly in English but certain headlines contain text in Devanagari.

From Options -> Set Default Font, I have chosen Hack 13 size as my default font.

But Hack is not a good font to display Devanagari characters.

So, when I want to edit contents of those headlines, I narrow the buffer to that region using C-x n s and using C-x C-e, evaluate the following command which is part of the headline:

(face-remap-add-relative 'default :family "Lohit Devanagari")

But that still changes the font for the entire buffer when I widen using C-x n w.

How do I achieve the behavior that I intend? Change the font back to the default when I widen?

1

You can use library narrow-indirect.el to help here.

Use command ni-narrow-to-region-indirect-other-window (I bind it to C-x 4 n n) to open an indirect buffer that shows just the current region (e.g. of Devanagari text).

There, you can use your (face-remap-add-relative 'default :family "Lohit Devanagari") to change that buffer's font, for Devanagari. The base buffer (and other indirect narrowing buffers) retains the font it had.

See Narrow Indirect for more information.


Update to answer your comment question:

Library narrow-indirect.el is not distributed with Emacs. It is available on the Emacs Wiki. You download it, put it in your load-path, and then require it, as follows:

  1. Right-click the narrow-indirect.el link, and choose Save Link As (or whatever your browser uses for this), to save the file.

  2. Save the file in a directory that is in your load-path: Put this in your init file:

     (add-to-list 'load-path "/YOUR/LISP/DIRECTORY/")
     (require 'narrow-indirect)
    

The first expression tells Emacs where to find the library. The second expression tells Emacs to load the library.

See the Emacs manual, node Lisp Libraries and the Elisp library, node How Programs Do Loading, for more info about this.

  • Thanks. This solution would have been perfect except that I am not able to locate narrow-indirect.el. So, when I try M-x ni-narrow-to-region-indirect-other-window, it shows no matches. When I tried looking for narrow-indirect using M-x list-packages or M-x load-library, there is no narrow-indirect. Am I missing something here? – deshmukh Feb 24 '18 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.