Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-23-2010, 02:11 PM
|
#1
|
|
LQ Newbie
Registered: Nov 2009
Posts: 15
Rep:
|
emacs in a terminal : problems with ctrl
Greetings.
I am one of those weirdos that likes running emacs from a terminal. I always do this because I sometimes must (when editing remotely through SSH), so I won't have to switch between a graphical editor and a terminal editor.
Usually, things work just fine. However, problems arise when I must send a "control-something" (like "C-RET" and "C-,") command to my editor. In graphical mode, this works fine. In a terminal, it does not.
In the current terminal that I am using (gnome-terminal), typing "C-RET" will send "C-j" to my editor. Furthermore, typing "C-," will send "," to my editor.
A non-solution would be to "not use these commands". However, I am using some major emacs modes (proofgeneral/coq-mode and agda2-mode), which have keyboard shortcuts like this:
"C-c C-RET"
"C-c C-,"
These are very useful shortcuts, and I am crippled without them.
So far, I am getting around this issue by adding to my .emacs configuration file an entry which makes emacs behave as expected when emacs receives this incorrect command:
(global-set-key (kbd "C-c C-j") 'proof-goto-point)
I would, however, prefer not to have to do this for every major mode I use. Furthermore, if a mode happens to use "C-c C-j", then this re-set keybinding will override it.
My question is the following:
PROBLEM: How do I ensure that emacs correctly interprets a "C-X" command, where X is *any* character?
A noteworthy detail here is that when I run emacs in an xterm, typing "C-," will in fact send "C-," to emacs. However, typing "C-RET" will send "C-<return>" to emacs. So the problem seems to be how the terminal translates a CTRL-something to a key, and sends it to emacs. So one solution could be to
SOL.1: Make sure your terminal sends the right signals to emacs.
However, this may not be possible (I am not about to dig into the belly of a terminal implementation, or to implement my own terminal emulator). Alternatively, we could accept that a terminal sends CTRL-something incorrectly to emacs / emacs interprets CTRL-something incorrectly. Accepting this, the solution to this problem would be to
SOL.2: Make sure emacs interprets the incorrect signals correctly.
A third option, which is probably the easiest one, is to realize that this is too challenging, and
SOL.3: Make sure that emacs reacts correctly when seeing "C-<return>", when emacs is run in an xterm.
(this seems to be the only problem with running emacs in an xterm.)
I am writing this here because I do not know how to proceed with any of these solutions, and am hoping someone here does.
Kind regards,
Willard.
|
|
|
|
06-23-2010, 05:22 PM
|
#2
|
|
Senior Member
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833
Rep: 
|
Typically this is related to your termcap, what terminal program are you using and what term are you telling the system that you're using? Do you have any additional keymaps?
|
|
|
|
06-23-2010, 07:50 PM
|
#3
|
|
LQ Newbie
Registered: Nov 2009
Posts: 15
Original Poster
Rep:
|
Quote:
Originally Posted by rweaver
Typically this is related to your termcap, what terminal program are you using and what term are you telling the system that you're using?
|
I am (was) using gnome-terminal. I followed this guide to make any application running in my terminal aware that I am using a terminal that can display more than 8 colours.
Code:
willard@naglfar:~
> env | grep TERM
TERM=xterm-256color
XTERM_SHELL=/bin/bash
XTERM_LOCALE=en_US.utf8
XTERM_VERSION=XTerm(256)
COLORTERM=gnome-terminal
Quote:
Originally Posted by rweaver
Do you have any additional keymaps?
|
I changed the way X treats "Caps Lock".
Code:
willard@naglfar:~
> cat .Xmodmap
remove lock = Caps_Lock
add control = Caps_Lock
I tried working more with xterm to have it understand all the CTRL-X I need, and realised that there is in fact no problem with "C-RET". However, "C-SPC" (control space) was a problem; emacs received "C-@". This seems to be the only issue with running emacs in an xterm.
Just in case this can cause problems, here are the configurations I made to xterm:
Code:
willard@naglfar:~
> cat .Xresources
xterm*foreground: gray
xterm*background: black
XTerm*metaSendsEscape: true
XTerm*font: 9x15
Xft.antialias: 1
Xft.hinting: 1
Xft.hintstyle: hintfull
Xft.dpi: 96
The xterm*metaSendsEscape: true turned out to be important, for else emacs would interpret "M-x" (alt x) as "ø" (a random forum somewhere suggested that this was an issue with using the UTF8 locale as opposed to the ISO8859-1 locale).
In case it is relevant, here is my (ugly) .emacs file.
Code:
willard@naglfar:~
> cat .emacs
;; Set default character encoding to UTF-8.
(set-language-environment "UTF-8")
(set-input-mode (car (current-input-mode))
(nth 1 (current-input-mode))
0)
(setq locale-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;; Replace tabs with spaces, etc.
(setq-default tab-width 8)
(setq-default c-basic-offset 4)
(setq-default indent-tabs-mode nil)
;; Have emacs store temporary files in ~/.emacs-backup.
(defvar user-temporary-file-directory "~/.emacs-backup")
(make-directory user-temporary-file-directory t)
(setq backup-by-copying t)
(setq backup-directory-alist
`(("." . ,user-temporary-file-directory)
(,tramp-file-name-regexp nil)))
(setq auto-save-list-file-prefix
(concat user-temporary-file-directory ".auto-saves-"))
(setq auto-save-file-name-transforms
`((".*" ,user-temporary-file-directory t)))
;; remove toolbar in graphical emacs
(tool-bar-mode -1)
;; remove scrollbar in graphical emacs
(scroll-bar-mode -1)
(if (null window-system)
(defvar config-is-graphical-window-system nil)
(defvar config-is-graphical-window-system t))
(setq auto-mode-alist (cons '("\\.jr$" . java-mode) auto-mode-alist))
(autoload 'flyspell-mode "flyspell" "On-the-fly spelling checker." t)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(autoload 'coq-mode "coq" "Major mode for editing Coq vernacular." t)
(autoload 'proofgeneral "proofgeneral" "Generic front-end for proof assistants." t)
;;(global-set-key (kbd "C-c C-j") 'proof-goto-point)
;;(global-set-key (kbd "C-c ,") 'agda2-goal-and-context-and-inferred)
;; proofgeneral customization
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(agda2-include-dirs (quote ("." "/home/willard/Programs/Installed/lib-0.3/src"))))
;; abda setup
(load-file (let ((coding-system-for-read 'utf-8))
(shell-command-to-string "agda-mode locate")))
Currently, I have switched from gnome-terminal to using xterm, and am doing alright so far. However, if I would be able to use gnome-terminal instead without trouble, I would be much happier. Any suggestions on how to do this are much appreciated.
Cheers,
Willard.
|
|
|
|
06-25-2010, 01:31 PM
|
#4
|
|
Senior Member
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833
Rep: 
|
Try switching to TERM=linux in gnome-terminal and see if things work correctly (modify the other relevent bits).
|
|
|
|
06-26-2010, 02:20 AM
|
#5
|
|
LQ Newbie
Registered: Nov 2009
Posts: 15
Original Poster
Rep:
|
Quote:
Originally Posted by rweaver
Try switching to TERM=linux in gnome-terminal and see if things work correctly (modify the other relevent bits).
|
Setting TERM=linux changed nothing; emacs in gnome-terminal will still interpret "C-c C-RET" as "C-c C-j", and similar badness for ".", ",", "SPC", and other characters.
|
|
|
|
09-13-2011, 04:18 PM
|
#6
|
|
LQ Newbie
Registered: Sep 2011
Posts: 1
Rep: 
|
I am in a similar boat (a vim user, forced to use emacs because of Proof General). I mostly ssh (using putty) to my workstation from a windows laptop, which doesn't run the entire X server stack. I was wondering if you found a solution to make gnome-terminal (and putty, which is more relevant for me) send the right keys? I read somewhere that C-j is "return" for emacs and so it seems to me that the terminals are simply omitting the Ctrl key.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:16 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|