Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
27
votes
5
answers
15776
views
How to get current buffer's filename in emacs?
One of the main features I miss about Vim, is that it always saves the filename of the current file in the `%` buffer ([more info][1]). That allows launching commands easily like: ;; compile current file :! gcc % ;; source current file (useful when I'm editing .vimrc :source % ;; get the size of cur...
One of the main features I miss about Vim, is that it always saves the filename of the current file in the
%
buffer (more info ). That allows launching commands easily like:
;; compile current file
:! gcc %
;; source current file (useful when I'm editing .vimrc
:source %
;; get the size of current file
:! du -sh %
;; etc, etc...
I would like to have similar functionality under emacs
(version 24, if that makes any difference), namely have an easy way to insert the name of the file opened in the current buffer.
**Examples of what I want to do**
*Here I describe some basic use cases as to explain better when I feel the need for such a shortcut*
1. Compile: When I enter M-x compile
emacs asks me for a compile command. I would like to enter gcc (current-buffer)
easily.
2. Load-file: When I'm editing my .emacs file, I would like to load it right away to test the changes. The way I do it is M-x load-file
and then I always spell out the name . e m a c s. I would like to have a shortcut.
3. Launch outside processes: I gave du -sh
as an example, only to illustrate that I want the shortcut to be also available when I execute shell commands with M-!
**What I found so far**
- This question here on U&L. The answers given are basically showing where to find the filename of a buffer so one can add it to the kill-ring. It's not exactly what I'm looking for, I don't want to have to manually kill the filename before I want to use it. (Also solutions described in both answers don't seem to work as smoothly in my emacs and require additional keystrokes making them a bit of a pain).
***EDIT**: A bit unrelated, by I found out why these solutions don't work. I have IDO enabled, for better or worse.*
- The (current-buffer)
function described in the manual does return the name of the file in the current buffer, but nowhere in the examples I gave above, am I evaluating elisp code. Is there a way to insert the result of the evaluation of this function in a (mini)buffer and binding this way to a shortcut?
**Am I wrong to think this way?**
I am currently learning to use emacs (it's been a few months actually) after years of using Vim. I want to avoid a predictable *using-emacs-in-a-Vim-way* trap. If you feel that what I'm asking for is not very *emacs-y*, and there should be a better (cleaner?) way to do it, please do mention it in your answers.
rahmu
(20511 rep)
Aug 9, 2012, 09:30 AM
• Last activity: Jul 18, 2025, 10:25 AM
30
votes
3
answers
24441
views
How can mouse support be enabled in terminal Emacs?
How can mouse support be enabled in an Emacs terminal session started with `emacs -nw`? Is there a keyboard shortcut or a flag to do this? If not how can it be done in terminal emulators? I use Guake.
How can mouse support be enabled in an Emacs terminal session started with
emacs -nw
? Is there a keyboard shortcut or a flag to do this? If not how can it be done in terminal emulators? I use Guake.
user
(2417 rep)
Jan 3, 2016, 11:51 AM
• Last activity: Jul 9, 2025, 08:30 AM
16
votes
3
answers
5435
views
Piping into less and editing: "cannot edit standard input" error. Workarounds?
I recently learned that if I page my files with `less`, I can press `v` and open the buffer in Emacs. This works as long as I have the environment variable `$EDITOR` set up correctly, which in my case I have it as: export EDITOR='env TERM=xterm-256color emacs -nw' The above gives me the ability to l...
I recently learned that if I page my files with
less
, I can press v
and open the buffer in Emacs. This works as long as I have the environment variable $EDITOR
set up correctly, which in my case I have it as:
export EDITOR='env TERM=xterm-256color emacs -nw'
The above gives me the ability to load emacs within the terminal that runs less
.
However, the trick above does not work when **piping** commands to less
. When doing this, less
complains with the following message:
Cannot edit standard input (press RETURN)
My question is, why does this happen? But most importantly, **is there any workaround to it**?
Amelio Vazquez-Reina
(42851 rep)
Oct 25, 2011, 09:49 PM
• Last activity: Jun 4, 2025, 08:17 AM
1
votes
1
answers
2008
views
"vncserver -compatiblekbd" fails with "Unrecognized option: -compatiblekbd"
I found that when I connect to my computing cluster via vnc `Alt-x` is not recognized correctly as`M-`. I tried vncserver -compatiblekbd but I get Unable to start Xvnc, exiting Actually once my session was started and in the log I found: Fatal server error: Unrecognized option: -compatiblekbd How ca...
I found that when I connect to my computing cluster via vnc
Alt-x
is not recognized correctly asM-
. I tried
vncserver -compatiblekbd
but I get
Unable to start Xvnc, exiting
Actually once my session was started and in the log I found:
Fatal server error:
Unrecognized option: -compatiblekbd
How can I pass this option to vncserver and get the correct mapping of Alt+x
?

simona
(1021 rep)
Feb 1, 2014, 09:00 PM
• Last activity: May 24, 2025, 11:07 PM
1
votes
0
answers
17
views
Idle time (tty st_atime) not updating when emacs is running
When running GNU emacs in a terminal (in the old-fashioned way, that is, i.e. *not* in its X windows mode) I've noticed that the `w` command shows the session as idle, even though emacs is active and accepting input. I know that `w` displays idle time based on st_atime on the login tty, which genera...
When running GNU emacs in a terminal (in the old-fashioned way, that is, i.e. *not* in its X windows mode) I've noticed that the
w
command shows the session as idle, even though emacs is active and accepting input.
I know that w
displays idle time based on st_atime on the login tty, which generally updates when the user types something and a program reads it. But for some reason st_atime isn't updating when emacs reads input. I wonder if that's due to emacs putting the tty in raw mode, or something?
Does anyone know? And is there any way around this? (I doubt it, but I have to ask.). I'm trying to do some idle-time-based auto shutdown, but I spend most of my time in emacs, and while I do plenty of things at the command line also, I could easily get false idle detections if my emacs time doesn't count.
Debian 10 and emacs 26.1, if it matters.
I'm sure there are "better" (more sophisticated, more complicated) ways of detecting idle time, and I suppose I'll have to pursue those.
----
Update: I tried the same thing on a different system, running Ubuntu 22.04, and did *not* see this behavior: activity in emacs does update st_atime on the tty, and so does reset idle time. (Also as it happens, the Ubuntu system is the one where I'm more interested in accurately detecting idle time, so my question is now practically moot, although I'd still be curious to know what's going on.)
Steve Summit
(918 rep)
Apr 25, 2025, 03:18 PM
• Last activity: Apr 25, 2025, 03:59 PM
0
votes
1
answers
56
views
How to ignore newly installed font unless specifically asked for?
I've installed a Japanese font ([this one](https://opentype.jp/kouzansousho.htm), if it makes any difference) that I wanted to use to practice reading cursive writing - i.e. it's deliberately very hard to read. However, it now appears to be my default for Japanese text in Chrome - e.g. on [this webs...
I've installed a Japanese font ([this one](https://opentype.jp/kouzansousho.htm) , if it makes any difference) that I wanted to use to practice reading cursive writing - i.e. it's deliberately very hard to read.
However, it now appears to be my default for Japanese text in Chrome - e.g. on [this website](https://www3.nhk.or.jp/news/easy/) . This is extra surprising as I have another font ([this one](https://www.nihilist.org.uk/) for practising stroke order) that doesn't get used, aside from when I specifically name it - which is by having it in some custom CSS on an SRS site. Emacs is also using neither of them as the default, for what it's worth - and the font does have characters from the Latin alphabet but the font for those hasn't changed, so maybe this is a language thing.
How do I tell Chrome not to use this font in preference to others?
I'm on a fresh Fedora 41 system.
John Graham
(101 rep)
Apr 14, 2025, 09:22 AM
• Last activity: Apr 16, 2025, 08:07 AM
1
votes
3
answers
327
views
Getting 'emacs-common-non-dfsg' from Debian bookworm-backports
This in reference to [this question](https://unix.stackexchange.com/q/758547/150047). Many thanks to user Marcus Müller for providing the silver bullet for getting Emacs 29 from Debian backports. I've done this already, and profited. However, one thing remains: the Emacs 28 documentation still...
This in reference to [this question](https://unix.stackexchange.com/q/758547/150047) . Many thanks to user Marcus Müller for providing the silver bullet for getting Emacs 29 from Debian backports. I've done this already, and profited.
However, one thing remains: the Emacs 28 documentation still lingers. I'm assuming I need to do
sudo apt install emacs-common-non-dfsg/bookworm-backports
, but this gives me a "referred to by another package" message. Perhaps this is a mistake from the Debian side (the backport author simply forgot to include the package)? Hopefully I can get the ball rolling from any insight into this matter.
bci_
(13 rep)
Oct 13, 2023, 01:19 AM
• Last activity: Mar 26, 2025, 07:48 PM
-1
votes
1
answers
18
views
function keys for emacs on a Linux VM
I have been using emacs for many years, and I have several common commands mapped to the function keys (at the top of the keyboard) for convenience. I am now trying to use emacs on a Red Hat 8 Linux virtual machine (VMware) under Windows. I am finding that I have to press the fn key (at the bottom o...
I have been using emacs for many years, and I have several common commands mapped to the function keys (at the top of the keyboard) for convenience. I am now trying to use emacs on a Red Hat 8 Linux virtual machine (VMware) under Windows. I am finding that I have to press the fn key (at the bottom of the keyboard) before I can use the function keys, which I never had to do before. This is a huge annoyance for me. Is there a way to make the function keys active without having to first hit the fn key? Thanks.
user36086
(1 rep)
Mar 18, 2025, 09:32 PM
• Last activity: Mar 19, 2025, 01:53 AM
27
votes
10
answers
12848
views
How to replace current word under cursor in Emacs
How do I replace current word under cursor in Emacs? I know that I can use query-replace or replace-string but every time I do so I have to type entire string to be replaced, this is just annoying. Vi has equivalent command cword and I can use a shortcut to pull the word under cursor for replacement...
How do I replace current word under cursor in Emacs?
I know that I can use query-replace or replace-string but every time I do so I have to type entire string to be replaced, this is just annoying.
Vi has equivalent command cword and I can use a shortcut to pull the word under cursor for replacement:
nmap z :%s#\=expand("")\>#
Anybody know how to do it with Emacs?
Think Pl
(483 rep)
Oct 14, 2012, 09:19 PM
• Last activity: Dec 30, 2024, 10:12 PM
3
votes
2
answers
854
views
How to get Guix perfect setup to work
The official Guix documentation describes [The Perfect Setup](https://guix.gnu.org/manual/en/html_node/The-Perfect-Setup.html) for hacking on Guix. I have followed this description and set up everything like described, but still Geiser does not work fully. I thought that this was supposed to give me...
The official Guix documentation describes [The Perfect Setup](https://guix.gnu.org/manual/en/html_node/The-Perfect-Setup.html) for hacking on Guix.
I have followed this description and set up everything like described, but still Geiser does not work fully. I thought that this was supposed to give me completion capabilities and make it possible to go to the definition of things. I can go to definition of some things, but only very few. Most things is not possible. Completion seems to be only based on text in the current buffer.
# My Emacs configurations
(use-package geiser
:ensure t
:custom
(geiser-default-implementation 'guile)
(geiser-active-implementations '(guile))
(geiser-implementations-alist '(((regexp "\\.scm$") guile))))
(use-package geiser-guile
:ensure t
:config
(add-to-list 'geiser-guile-load-path "/home/lars/code/forks/guix")
(add-to-list 'geiser-guile-load-path "/home/lars/code/guix/modules")
(add-to-list 'geiser-guile-load-path "/home/lars/code/guix"))
(with-eval-after-load "geiser-guile"
(add-to-list 'geiser-guile-load-path "/home/lars/code/forks/guix")
(add-to-list 'geiser-guile-load-path "/home/lars/code/guix/modules")
(add-to-list 'geiser-guile-load-path "/home/lars/code/guix"))
# REPL
I invoke the Geiser REPL in Emacs with M-x geiser-guile
or M-x geiser
.
The output in the Geiser REPL looks like this:
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)>
Note that the prompt says guile-user
, but I think it should say guix-user
.
However, if I start the Guix REPL by running guix repl
in a terminal the output looks like this:
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guix-user)>
Note that here it says guix-user
.
When trying to 'use' the guix
module in Geiser REPL:
,use (guix)
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/lars/code/forks/guix/guix.scm
;;; compiling /home/lars/code/forks/guix/guix/packages.scm
;;; compiling /home/lars/code/forks/guix/guix/utils.scm
;;; WARNING: compilation of /home/lars/code/forks/guix/guix/utils.scm failed:
;;; no code for module (guix config)
;;; WARNING: compilation of /home/lars/code/forks/guix/guix/packages.scm failed:
;;; no code for module (guix config)
;;; compiling /home/lars/code/forks/guix/guix/store.scm
;;; WARNING: compilation of /home/lars/code/forks/guix/guix/store.scm failed:
;;; no code for module (guix config)
;;; WARNING: compilation of /home/lars/code/forks/guix/guix.scm failed:
;;; no code for module (guix config)
;;; compiling /home/lars/code/forks/guix/guix/derivations.scm
;;; compiling /home/lars/code/forks/guix/guix/diagnostics.scm
;;; WARNING: compilation of /home/lars/code/forks/guix/guix/diagnostics.scm failed:
;;; Unbound variable: trivial-format-string?
;;; WARNING: compilation of /home/lars/code/forks/guix/guix/derivations.scm failed:
;;; no code for module (gcrypt hash)
While executing meta-command:
no code for module (gcrypt hash)
scheme@(guile-user)>
Doing the same in a Guix REPL works fine:
scheme@(guix-user)> ,use (guix)
scheme@(guix-user)>
# Go to definition
Go to definition works in some places, for example in the line below:
(gnu home services)
This takes me correctly to the source of gnu home services.
However, trying to go to the definition of packages does not work:
(packages (list
htop
git
alacritty
tmux))
Trying to go to the definition of any of the packages in the package list just does not work.
# Completion
I would expect to be able to get completions for modules and packages (among other things) by typing the start of the name of the packages, but nothing comes. Sometimes I get some random completion based on random text in the same buffer, but most of the time not even that.
lrustand
(41 rep)
Nov 18, 2023, 03:37 PM
• Last activity: Dec 19, 2024, 03:07 PM
3
votes
3
answers
3628
views
How to set up an OpenRC service to run at "login" level?
I want a specific service of OpenRC to run after my user login through agetty, LightDM (display manager), or any other way. This is because I have a emacs daemon running as OpenRC service for my specific user and I need this service to start only after a dbus session is created. One way to accomplis...
I want a specific service of OpenRC to run after my user login through agetty, LightDM (display manager), or any other way.
This is because I have a emacs daemon running as OpenRC service for my specific user and I need this service to start only after a dbus session is created. One way to accomplish this is to run emacs daemon after dbus-launch [(related history)] runs my main session (currently XFCE session), which for instance happens after a login through the LightDM display manager .
What I do as workaround is: restart emacs after login with my user to initialize correctly dbus integration with emacs. But this is just painful. There must be a better way to do that.
Manoel Vilela
(362 rep)
Nov 27, 2017, 04:32 AM
• Last activity: Aug 30, 2024, 04:07 AM
0
votes
1
answers
60
views
F10 keybinding of unknown origin (maybe Gnome?)
I am running Fedora 40 which I installed a few months ago. I noticed that `F10` in my Emacs does not run the function that I have assigned to it in Emacs: in fact, Emacs does not see the `F10` key any longer (and I am pretty sure that this started happening when I upgraded to Fedora 40: it was worki...
I am running Fedora 40 which I installed a few months ago. I noticed that
F10
in my Emacs does not run the function that I have assigned to it in Emacs: in fact, Emacs does not see the F10
key any longer (and I am pretty sure that this started happening when I upgraded to Fedora 40: it was working fine in Fedora 38 - I skipped Fedora 39).
I can tell that Emacs does not see the key by using C-h C-k
, the help function to describe a key, and pressing F10
. Usually, the key is echoed in Emacs's echo area and the command bound to it is reported. In the F10
case, nothing is echoed in the echo area. Instead the File
menu is dropped down.
That behavior seems to be somewhat general: both Firefox
and Thunderbird
exhibit the same behavior, which is another reason to conclude that the desktop environment is what's doing this. Not every application does this however: in gnome-terminal
and xterm
, F10
apparently just generates an escape sequence: ^[[21~
.
I did gsettings list-recursively
and found one entry using F10
: that looked promising, so I set it to empty:
$ gsettings get org.gnome.desktop.interface menubar-accel
'F10'
$ gsettings set org.gnome.desktop.interface menubar-accel ''
$ gsettings get org.gnome.desktop.interface menubar-accel
''
but that didn't do anything AFAICT (after various levels of restarting: restarting Emacs, logging out and back in, rebooting, shutting down and starting from scratch). As far as I know, all the graphical widget thingies (Settings, Tweaks, etc.) are using the Gsettings API underneath, so this *should* have found the culprit - but no dice.
Since Emacs is built with libgtk-3.0, I also tried a GTK setting as described in [this answer](https://unix.stackexchange.com/a/40685/230615) but that also did not make any difference.
Although my main interest is to free up F10
from whoever its current master is and allow it to be passed to Emacs, I'd also be interested in any tips/hacks/methods you have come up with to deal with similar problems. Any ideas?
Version info:
- OS: Fedora 40
- Kernel: Linux 6.9.12-200.fc40.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Jul 27 15:56:15 UTC 2024 x86_64 GNU/Linux
- Gnome: 46.3
- Emacs: bleeding-edge upstream, unreleased (31.0.50), but it also happens in the Emacs that comes with Fedora 40: GNU Emacs 29.4 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.42, cairo version 1.18.0) of 2024-07-16
If more information is needed, I'd be happy to supply it: please let me know.
UPDATE: in response to the comment by David G. below, xev
does see F10
(and so do gnome-terminal
and xterm
as mentioned above, and of course whatever makes the File
menu to drop down in the case of Emacs
, Firefox
and Thunderbird
). The problem is not that it is not seen: the problem is that it is grabbed before I want it to be grabbed and I don't know what grabs it. That's what I'm trying to find out in the hope that I can convince that something to keep its hands off my F10
:)
In response to further comments by David G. (thanks for the responses and for keeping me honest!), I tried emacs -Q
which starts Emacs without any initialization files (either site-init (site-start.el
or user-init or early-init). But the GTK suggestion is intriguing. I built an Emacs without a toolkit at all and it behaves as expected wrt to F10
: the key is visible and I can bind it to a command. I then found [this section](https://docs.gtk.org/gtk4/class.Window.html#shortcuts-and-gestures) in the GTK documentation: it's about GTK4 and I cannot find the equivalent in the GTK3 documentation, but I'm assuming that the behavior is the same in the two versions. I'm no GTK programmer, so I don't know how to turn this behavior off yet, but it seems clear that David G. was right when he fingered the GTK interface in Emacs as the culprit.
NickD
(3018 rep)
Aug 9, 2024, 05:51 PM
• Last activity: Aug 11, 2024, 01:38 AM
0
votes
1
answers
375
views
XFCE: M-Tab, active windows and „Always on Top“
I run XFCE under X11 with focus policy „focus follows mouse“. What happens when I open an application, create a new (second) window in it, set it to „Always on Top“ from window menu, move the mouse pointer into it, and press M-Tab (aka Alt-Tab)? It has turned out in my experiments that different app...
I run XFCE under X11 with focus policy „focus follows mouse“. What happens when I open an application, create a new (second) window in it, set it to „Always on Top“ from window menu, move the mouse pointer into it, and press M-Tab (aka Alt-Tab)? It has turned out in my experiments that different applications behave differently in this respect. For Okular, Thunar and Firefox, pressing M-Tab results in the first window becoming active; for XFCE Terminal and Emacs, the second window remains active as long as the mouse pointer is in it, and there seems to be no way to make the first window active using the keyboard. What does this behavior depend on? How could I make Emacs behave like Okular so that I don't have to reach for the mouse to make the non-always-on-top window active?
My version of XFCE is 4.18.
toomas
(170 rep)
Jul 17, 2024, 03:19 PM
• Last activity: Jul 19, 2024, 12:42 AM
0
votes
0
answers
116
views
Disable colors in emacs terminal
How to disable all colours in `emacs` _running in a terminal_? Note that I don't want disabling just a buffer. I don't want `(global-font-lock-mode 0)` because that only works on normal buffers, however `emacs` sometimes asks me questions in the mini-buffer in unreadable blue text, so I want to disa...
How to disable all colours in
emacs
_running in a terminal_?
Note that I don't want disabling just a buffer.
I don't want (global-font-lock-mode 0)
because that only works on normal buffers, however emacs
sometimes asks me questions in the mini-buffer in unreadable blue text, so I want to disable colours altogether. Alternatively a settings which just disables colours for the mini-buffer.
ccthecc
(1 rep)
Jun 21, 2024, 05:11 AM
• Last activity: Jun 21, 2024, 12:13 PM
0
votes
0
answers
44
views
Add LC_CTYPE to Desktop Entry
I'm using fcitx5 with emacs, to enable entry of Chinese characters. There is a [known issue with emacs][1], where in order to input Chinese characters, one needs to launch emacs using `LC_CTYPE=zh_CN.UTF-8 emacs`. This works fine, but I would like to make this more permanent (for lack of better word...
I'm using fcitx5 with emacs, to enable entry of Chinese characters. There is a known issue with emacs , where in order to input Chinese characters, one needs to launch emacs using
LC_CTYPE=zh_CN.UTF-8 emacs
. This works fine, but I would like to make this more permanent (for lack of better word).
One thing I would like to do is change the Desktop Entry file to set LC_CTYPE
. The reason I want to change this file is because I have different symlinks pointing to it (like autostart), and would like to launch this entry with the edited LC_CTYPE
. Is this possible?
My Desktop Entry file in /usr/share/applications/
looks like this:
[Desktop Entry]
Version=1.0
Name=Emacs (GUI)
GenericName=Text Editor
Comment=GNU Emacs is an extensible, customizable text editor - and more
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
TryExec=/usr/bin/emacs
Exec=/usr/bin/emacs %F
Icon=emacs
Type=Application
Terminal=false
Categories=Utility;Development;TextEditor;
StartupWMClass=Emacs
Keywords=Text;Editor;
GNUser
(101 rep)
May 2, 2024, 04:42 PM
0
votes
1
answers
150
views
xterm seems to change its "home" key behaviour for emacs
In xterm, when I press the HOME key on my keyboard, it normally sends `^[[H` but when I open `emacs -nw`, it changes to `^[OH`; those are `home` and `khome` respectively. I figured out while trying to build my own terminal that `^[[H` doesn't work in emacs. However, I can't figure what causes xterm...
In xterm, when I press the HOME key on my keyboard, it normally sends
meanwhile in a different terminal (that doesn't have to be xterm), copy the emacs pty settings:
^[[H
but when I open emacs -nw
, it changes to ^[OH
; those are home
and khome
respectively. I figured out while trying to build my own terminal that ^[[H
doesn't work in emacs. However, I can't figure what causes xterm (or emacs) to change its behaviour.
Additionally
* The keys that "should" correspond to home
and khome
(the home key I usually use, and 1 on the keypad with numlock off) - always do the same thing on every terminal I have tried even though xev shows they are different, so for the rest of the question, I will treat them as the same thing.
* It doesn't seem to relate to pty settings. I have used stty -g
to copy the settings with emacs on, and then applied them with cat -v
running, and I still get the non emacs behaviour. (demo below)
* bash's readline seems to be more accepting than emacs and/or read the TERM variable, because HOME always works in bash no matter what terminal I try
----
Here are my experiments:
##### xterm
get terminal info:
$ tty
/dev/pts/1
$ echo $TERM
xterm
$ infocmp $TERM | grep home
el1=\E[1K, flash=\E[?5h$\E[?5l, home=\E[H,
kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~,
try the HOME key, and then return with cat -v
and then exit
$ cat -v
^[[H
^[[H
^C
open emacs
$ emacs -nw
try out behaviour of home key
(it works - I won't post a video)
use C-q
to see what the key is sending:

$ emacs_settings=$(stty -F /dev/pts/1 -g)
$ echo $emacs_settings
4001:1:bf:a31:7:7:7f:15:4:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:
and then quit emacs and start cat -v
again
$ cat -v
and then back to the second terminal - set the xterm pty back to the settings that emacs uses
$ stty -F /dev/pts/1 $emacs_settings
and press home again in xterm:
(and then press return and quit)
$ cat -v
^[[H^M
It's the same as it always is outside of emacs, the home
code, not the khome
code that somebody is helpfully inserting inside emacs.
Now if you are trying this at home, and want to quit cat -v
, you will need to use ctrl+G instead of ctrl+C because the emacs settings change some keys around. This proves the settings worked. You can also see there that there is no ^G at the end of the line from quitting, but there is a piece of carriage return - I guess because the echo settings changed, and it's in raw mode.
Here are the human readable emacs pty settings if you are curious.
$ stty -F /dev/pts/1 -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^G; quit = ^G; erase = ^?; kill = ^U; eof = ^D; eol = ; eol2 = ; swtch = ; start = ; stop = ; susp = ;
rprnt = ; werase = ; lnext = ; discard = ; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig -icanon -iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc
----
Other terminals
##### linux
$ infocmp linux | grep home
home=\E[H, hpa=\E[%i%p1%dG, ht=^I, hts=\EH, ich=\E[%p1%d@,
kf8=\E[19~, kf9=\E[20~, khome=\E[1~, kich1=\E[2~,
this one isn't easy to take a screenshot (I could photograph it but I haven't)
The summary is - whether you are in emacs or not, the HOME key sends khome
from the terminal settings, and it always works in emacs.
##### MATE Terminal (xterm-256color
)
$ echo $TERM
xterm-256color
$ infocmp $TERM | grep home
el1=\E[1K, flash=\E[?5h$\E[?5l, home=\E[H,
kf8=\E[19~, kf9=\E[20~, khome=\EOH, kich1=\E[2~,
$ cat -v
^[[H
^[[H
^C
but again it sends ^[OH
inside emacs! So again they are different. I don't know how I missed this before. I guess MATE terminal implements exactly what xcode does, or uses some of the same components.
On the other hand:
##### Hyper (xterm-256color
)
In this case, they just send khome
all the time, and the HOME key still seems to work how you would expect it to work.
$ echo $TERM
xterm-256color
$ cat -v
^[OH
^[OH
^C
$ emacs -nw
$ # ... ^[OH again
##### tmux (in MATE terminal) screen
I don't know when tmux sets TERM
to screen
and when it sets it to tmux
, but today on this computer, in this host terminal, it's screen
.
$ echo $TERM
screen
$ infocmp $TERM | grep home
enacs=\E(B\E)0, flash=\Eg, home=\E[H, hpa=\E[%i%p1%dG,
khome=\E[1~, kich1=\E[2~, kmous=\E[M, knp=\E[6~, kpp=\E[5~,
$ cat -v
^[[1~
^[[1~
^C
$ emacs -nw
$ # also ^[[1~ with C-q inside emacs
------
##### round-up
* Some terminals just send khome
all the time, while others manage to send khome
inside emacs and home
the rest of the time.
* khome
and home
both work for bash readline, but only khome
works in emacs - or there is just a fixed list of home keys that work in emacs (I am talking about default config) - I am leaning toward the fixed list since I can't get emacs behaviour to change by changing TERM
##### the big question
How xterm (and MATE Terminal) manages to change which code it sends when emacs is open.
Here are some guesses I can think of:
a) xterm has a special rule emacs
b) emacs has a special rule about xterm
c) emacs does change the terminal settings to cause this, but whatever that setting is, cat
continually changes back if you try to make cat use that setting
##### smaller questions worth mentioning
* Why don't the keys that look like they correspond to home
and khome
send the corresponding values?
* Does emacs (by default) change its behaviour based on TERM
?
Alex028502
(643 rep)
Apr 13, 2024, 05:40 PM
• Last activity: Apr 14, 2024, 05:16 AM
1
votes
1
answers
250
views
Fontawesome icons are not pasted correctly
I am using Fedora and installed fontawesome via `sudo dnf install fontawesome fonts`. Later because it didn't work I also additionally installed the font manually via downloading the zip from the Github page and following [these instructions][1]. When I copy a icon, e.g. the Firefox Icon via "Copy...
I am using Fedora and installed fontawesome via
sudo dnf install fontawesome fonts
. Later because it didn't work I also additionally installed the font manually via downloading the zip from the Github page and following these instructions .
When I copy a icon, e.g. the Firefox Icon via "Copy Glyph" from this Website and then I paste it into my Vim or Emacs, not the Firefox logo ist pasted, but instead a checkmark appears. The same happens, when I insert it with the unicode insertion e.g. ctr+v u+e007
.
The same principle also happens with other icons: another unicode character which is not the icon appears. E.g. instead of for the Signal Messenger Icon , a cup with a straw appears. The output of file -bi
on the file is text/plain; charset=utf-8
so the encoding is utf-8.
How can I paste it correctly?
For context: I am trying to configure the i3 bar to use icons, but since I am unable to paste them into the configuration file, this doesn't work. I searched for similar questions, but all the questions regarding the fontawesome font icons were about displaying them correctly, not pasting them correctly. I nevertheless tried some of the solutions, which didn't work.
Sinthoras
(23 rep)
Apr 2, 2024, 05:51 PM
• Last activity: Apr 4, 2024, 03:50 PM
1
votes
1
answers
193
views
Make Emacs load .bashrc / .bash_profile when started by GUI
I wrote `LD_LIBRARY_PATH` both in `.bashrc` and `.bash_profile`. However, if I started emacs in terminal using `emacs`, `LD_LIBRARY_PATH` is shown in `getenv`. If I started it using GUI (installed from apt-get), there is no such variable. I am on ubuntu 20.04. How could I make GUI started emacs have...
I wrote
LD_LIBRARY_PATH
both in .bashrc
and .bash_profile
.
However, if I started emacs in terminal using emacs
, LD_LIBRARY_PATH
is shown in getenv
.
If I started it using GUI (installed from apt-get), there is no such variable.
I am on ubuntu 20.04. How could I make GUI started emacs have the same env vars as terminal started one?
spacegoing
(111 rep)
Jul 12, 2020, 11:06 AM
• Last activity: Mar 29, 2024, 08:19 PM
4
votes
4
answers
1028
views
Emacs - Changing show-paren-mode Areas
I like show-paren-mode in Emacs, but I would really like to change the highlighting behavior for closing brackets. That is, I want the opening bracket to be highlighted when the point is on the closing bracket. The default behavior highlights the opening bracket when the point is on the character fo...
I like show-paren-mode in Emacs, but I would really like to change the highlighting behavior for closing brackets.
That is, I want the opening bracket to be highlighted when the point is on the closing bracket. The default behavior highlights the opening bracket when the point is on the character following the closing bracket.
Is this easy to change? Also, I would be interested in potential benefits of keeping the show-paren-mode behavior as it is.
user22531
Nov 4, 2013, 07:33 PM
• Last activity: Feb 28, 2024, 04:34 PM
1
votes
0
answers
53
views
Emacs hangs the network when C-g or M-x keyboard-quit, what does keyboard-quit do behind the scenes?
Working with emacs on a new RH8 network accessed from a remote windows machine using VNC. Emacs is running on RH8. Starting from emacs -Q when I perform C-g or M-x keyboard-quit emacs hangs and the network seems to hang. At that point, I no longer have access to the other programs or the terminal, a...
Working with emacs on a new RH8 network accessed from a remote windows machine using VNC.
Emacs is running on RH8.
Starting from emacs -Q
when I perform C-g or M-x keyboard-quit emacs hangs and the network seems to hang.
At that point, I no longer have access to the other programs or the terminal, access and the screen is frozen.
I have to quit out of the double hop windows virtual session I am in to regain control.
My question is:
**What does keyboard-quit do behind the scenes that could trigger this behavior**?
Bonus points for how to debug this.
For example when running M-x keyboard-quit does emacs:
- Check something external to emacs?
- Allocate or releasing memory?
- Perform garbage collection?
- Write out history or logging?
- Try to ping some ip?
- Something else like this?
I have repeated this experiment with versions (not all versions) of emacs from emacs 26.1 thru emacs 29. Don't think it has anything to do with the emacs version.
I don't think its something else grabbing the key binding; can repeat the issue just by starting from emacs -Q, then M-x keyboard-quit, and the session is hung up.
Not loading libraries/packages between emacs -Q and M-x keyboard-quit.
Based on this, I don't think its anything I am doing with in my config (.emacs file).
Some of the versions of emacs were build locally in my home dir. Some were installed my someone with superuser and RH installer.
When I run emacs -Q, there are no messaged displayed in the terminal. At that time all seems well.
The lockup lasts about 30s-1min for emacs -Q.
If I launch with my full emacs configuration the lockup lasts longer.
Mikef
(111 rep)
Feb 23, 2024, 05:07 PM
• Last activity: Feb 23, 2024, 05:17 PM
Showing page 1 of 20 total questions