Hot answers tagged

47

Note that as of Emacs 27, you should probably use the built-in display-fill-column-indicator-mode, as noted by the newer answer from Basil. fill-column-indicator is the most mature solution, and if you find overlay-based code with which it conflicts, you can add code to suspend fci-mode while the conflicting code is active. For example, the following code ...


37

Are there any better alternatives? Emacs 27 (officially released 2020-08-11) added support for a fill column indicator natively by way of the buffer-local minor mode display-fill-column-indicator-mode and its global counterpart global-display-fill-column-indicator-mode (see (info "(emacs) Minor Modes")). For example, you can enable it in most ...


25

Here is one option which is more robust, it breaks almost nothing (occasionally company-mode being a noteworthy exception), but is not as convenient as fill-column-indicator. Use header-line-format to mark the 80th column on the header. Something like the following should suffice: (setq-default header-line-format (list " " (make-string 79 ?-...


19

After much suffering because of various bugs fill-column-indicator introduces, I eliminated it from my config for good. What I currently use is built-in Emacs functionality to highlight lines that are too long. This even looks better, I wouldn't enable fill-column-indicator now even if it were bug-free. For a start you may grab my setup: (setq-default ...


13

Emacs comes with elide-head.el which does exactly what you're asking for. To use it, add elide-head to a major mode hook or find-file-hook (in your case c-mode-common-hook should work). It can hide GPL license comments out of the box; to hide other lengthy headers, customize elide-head-headers-to-hide. Note that it does not hide just any comment at the top ...


12

Here's one way to do that: Add this to your init file: (defun hide-banner () (save-excursion (let* ((start (progn (beginning-of-buffer) (point))) (end (progn (forward-comment (buffer-size)) (point))) (over (make-overlay start end))) (overlay-put over 'invisible t)))) In the buffer where you want to hide the initial ...


10

emacs for now doesn't support ligatures (on OSX there is some support, but not on other platforms). However, emacs 24.4+ supports prettify-symbols-mode which in some ways is better than normal ligatures support. That mode allows to subsitute for display any regex with any glyph. I am personnally using this snippet to get Fira Code ligatures to work in emacs ...


10

And again we have a use-case for image data not stored on harddisk. (The other two use-cases are base64 encoded images in org buffers and displaying previews of youtube videos.) Get org-yt and paste the following elisp code into your init-file. After evaluating your init-file you can use links analog to the example: [[imghttp://tn-home.de/Pic/tn-home.png]]...


9

I don't use Emacs on Windows, nor do I use xwidgets, but I do know that Emacs has to be compiled with xwidgets (since some of its stuff is written in C) for it to work. Taking a cursory look at the configure options for Emacs, I see a particular option for compiling Emacs with xwidgets: --with-xwidgets enable use of some gtk widgets in Emacs buffers ...


8

edit: With Emacs 26.1 or later, it's a (setq display-raw-bytes-as-hex t) away. No, you can't. The display of unprintables above the printable ASCII range is hardcoded in xdisp.c: if (CHAR_BYTE8_P (c)) /* Display \200 instead of \17777600. */ c = CHAR_TO_BYTE8 (c); len = sprintf (str, "%03o", c + 0u); I sent a patch fixing this to debbugs.


7

This EmacsWiki page is about Ruler Mode, a minor mode that shows a ruler for columns at the top of a window. It also shows you the current column and the positions of comment-column, fill-column, goal-column, and the tab stops (as in tab-stop-list). And this EmacsWiki page is about a ruler that pops up on demand, then disappears. This other EmacsWiki page ...


7

You can customize indicate-empty-lines to enable a fringe marker on lines after the end of the file, or call toggle-indicate-empty-lines to turn it on and off interactively. There's a package on MELPA that replaces the default fringe indicator with a ~ for a look that is closer to what you get with vi. See vi-tilde-fringe. Updated An alternative approach ...


7

Function display-monitor-attributes-list gives you a list of the physical monitor attributes. This includes the display name (e.g., ".DISPLAY1"), which might be all you need. Dunno.


7

Prettify-symbols-mode comes with emacs; here's a blog post about it. You need to add the substitution to prettify-symbols-alist in whatever mode you want it in. Here's an example for javascript-mode: (add-hook 'javascript-mode-hook (lambda () (push '("function" . ?λ) prettify-symbols-alist))) and then M-x prettify-symbols-mode To avoid ...


6

In the release log of emacs:(http://www.gnu.org/software/emacs/news/NEWS.24.5) * Installation Changes in Emacs 24.3 ** The default X toolkit is now Gtk+ version 3. If you don't pass `--with-x-toolkit' to configure, or if you use `--with-x-toolkit=gtk' or `--with-x-toolkit=yes', configure will try to build with Gtk+ version 3, and if that fails, try Gtk+ ...


6

Not exactually what you want, but ruler like @Malabarba♦ will waster space, here is better solution: There is a built-in package in emacs-goodies-el(recommend to install it in terminal) called highlight-beyond-fill-column.el, add this to your .emacs or init.el: (setq-default fill-column 80) (add-hook 'prog-mode-hook 'highlight-beyond-fill-column) (custom-...


6

What you want to do is to set the display-table entry for character LEFT-TO-RIGHT EMBEDDING to the glyph that is used for character SECTION SIGN. (aset (or (window-display-table) standard-display-table) 8234 ; 0x202A, which is the char LEFT-TO-RIGHT EMBEDDING (vector (make-glyph-code ?§))) If the selected window has its own display table, then ...


6

I figured it out thanks to the answer by Gilles and the 2010/2011 thread on gnu.emacs.help called “How switch from escaped octal character code to escaped HEX?” (Google Groups, Nabble). The details of how Emacs displays characters are in the section Display > Text Display (“How Text Is Displayed”) of the Emacs manual (C-h r), and section Display > Character ...


5

To expand on Tarsius' answer. display-pixel-width and display-pixel-height return the width and height respectively. display-monitor-attributes-list will give you information on all the available monitors attached to the DISPLAY. If you're dealing with a multi-monitor situation you'll probably need: (assq 'workarea (nth X (display-monitor-attributes-list)...


5

There is a mode for that: centered-cursor-mode. It can be installed from MELPA. It does not play well with a couple of modes, so this is my configuration: ;; keep the cursor centered to avoid sudden scroll jumps (require 'centered-cursor-mode) ;; disable in terminal modes ;; http://stackoverflow.com/a/6849467/519736 ;; also disable in Info mode, because ...


5

A trick that can work is to edit a variable-width font to adjust the bounding boxes of its characters, effectively making it monospace. There are some caveats: The exact width depends on which monospace font one wants to use it with. Wide characters will bleed a bit onto neighbouring spaces (though they can be slightly shrunk to mitigate the issue) Kerning ...


5

This depends on the fonts you are using. And I don't think Elisp has pixel level alignment capability. Org calculate width of string with string-width instead of length. string-width returns 1 for ASCII and Half width CJK chars or 2 for Full width chars. Evaluate the following code will show you that: (string-width "m") 1 (string-width "ハ") 1 (string-...


5

The built-in line numbering mechanism uses the text-area that is sandwiched between the left/right fringes and/or left/right margins, to the extent that fringes/margins exist. [What happens internally is that the line number glyphs (with a space on each end) are prepended to the glyphs of the display line within the text area.] Thus, setting the fringe or ...


4

Someone wrote a package that manages an overlay spanning the area after the end of the file: https://github.com/jmickelin/vim-empty-lines-mode Keep in mind though that while this solution behaves more correctly and works in terminals as well, it will necessarily be less performant and more buggy than the fringe indicator one.


4

Since Emacs 23, you no longer need to care whether Emacs was started from inside X. Start Emacs however you like, possibly as a daemon. Open and close frames on any display as desired. Start Emacs with emacs --daemon then when you want to edit a file, run emacsclient MYFILE or if you just want to create a frame, run emacsclient -c which will create an ...


4

Yes. See pretty-symbols package. It can look like this, for example, when coding Python, or any other language:


4

The problem lies in the self compiled libjpeg-9.dll. It is solved by downloading dll files from ezwinports as recommended: Emacs can also support some other image formats with appropriate libraries. These libraries are all available on the following sites: 1. http://sourceforge.net/projects/ezwinports/files/ -- leaner, more up-to-date builds, only for ...


4

Use display-pixel-width and display-pixel-height.


4

I've written a package, char-font-lock, that (among else) highlight empty lines at the end of a buffer. It also highlights the last line (in case it doesn't end with a newline), space at the end of lines, tab characters, and non-ascii characters. You can cherry pick which of the things you would like to highlight. For example:


Only top voted, non community-wiki answers of a minimum length are eligible