all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* keymap problem
@ 2005-03-20  5:43 no spam
  2005-03-20 16:14 ` Joe Corneli
  0 siblings, 1 reply; 10+ messages in thread
From: no spam @ 2005-03-20  5:43 UTC (permalink / raw)


I've been given an account on a university system running Linux, and the 
     Emacs version is 21.2.1.   The problem is, I cannot figure out how 
to make my Backspace key work properly.  Or rather, I can, sort of, but 
only by typing global-set-key each time.

Before you say "so put that in your .emacs file, and off you go" -- I've 
been trying to do that, but can't make it work.

Details:

I'm running Fedora Core 3 and using ssh to get to the host.

if I do M-x global-set-key while in Emacs, when I hit Backspace, it 
displays it as C-d (First clue something isn't right).  How do I change 
this binding, so that my Backspace is really mapped to a backspace, and 
not C-d?

If I give it the function 'delete-backward-char', then Backspace AND C-d 
do the same thing, which is a slight improvement, but not really what I 
want.


and putting

(global-set-key [backspace] 'delete-backward-char)

or

(global-set-key [DEL] 'delete-backward-char)

in the .emacs file doesn't work:  Backspace still deletes forward.


Moreover, C-h on this system is currently the way to get backspace 
functionality, not "help" as it should be.

So how do I fix all this?  I've been poring over the Gnu emacs website 
and I know it has something to do with the keymaps, but I haven't quite 
managed to figure it out.  Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: keymap problem
  2005-03-20  5:43 keymap problem no spam
@ 2005-03-20 16:14 ` Joe Corneli
  2005-03-20 16:16   ` Joe Corneli
       [not found]   ` <mailman.4482.1111337221.32256.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: Joe Corneli @ 2005-03-20 16:14 UTC (permalink / raw)


You can always use M-x help RET k KEY until you figure out what all
your keys are bound to.  For example, if I use command and hit the big
key on the upper-right corner of the keyboard when KEY is needed,
a help window is brought up that says 

DEL (translated from <backspace>) runs the command previous-line
   which is an interactive compiled Lisp function in `simple'.

[Bla bla bla.]

Then I type M-x command-history, and I see

(describe-key "^?" 1 nil)

where the ^ and the ? are all part of one control character.

All you need to do next is cut and paste that form into your .emacs
and then edit it into a `global-set-key' form to do whatever you want,

(global-set-key "^?" 'delete-backward-char-untabify)

for example.  That should be enough to get you started?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: keymap problem
  2005-03-20 16:14 ` Joe Corneli
@ 2005-03-20 16:16   ` Joe Corneli
       [not found]   ` <mailman.4482.1111337221.32256.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Joe Corneli @ 2005-03-20 16:16 UTC (permalink / raw)
  Cc: help-gnu-emacs

Or rather `backward-delete-char-untabify' but if you had a function
`delete-backward-char-untabify' you could use the binding strategy
above to bind to it!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: keymap problem
       [not found]   ` <mailman.4482.1111337221.32256.help-gnu-emacs@gnu.org>
@ 2005-03-20 17:47     ` no spam
  2005-03-20 18:11       ` Joe Corneli
       [not found]       ` <mailman.4492.1111343289.32256.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: no spam @ 2005-03-20 17:47 UTC (permalink / raw)


thanks, Joe, but there are still a few problems:

1) if I do M-x help k   (the Backspace key)   I get

C-d runs the command delete-char
(delete-char N   ............)


which means that backspace has already been mapped to C-d (that's why I 
suspected this required some sort of keymap wizardry).  While I could 
live with C-d and Backspace both meaning delete-backward-char,
I'd really rather have C-d continue to mean "delete forward" like it 
ought to.


2) your syntax doesn't work in my version:  If I try

(global-set-key "^d" 'backward-delete-char-untabify)

I get an initialization error "Key sequence ^ d uses invalid prefix 
characters"

I've also tried [C-d] which didn't get an error but also didn't have the 
  desired effect.  Neither did this:

(global-set-key [delete] 'backward-delete-char-untabify)

So how do I prevent Backspace from being mapped to C-d?


Joe Corneli wrote:
> Or rather `backward-delete-char-untabify' but if you had a function
> `delete-backward-char-untabify' you could use the binding strategy
> above to bind to it!
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: keymap problem
  2005-03-20 17:47     ` no spam
@ 2005-03-20 18:11       ` Joe Corneli
       [not found]       ` <mailman.4492.1111343289.32256.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Joe Corneli @ 2005-03-20 18:11 UTC (permalink / raw)



   which means that backspace has already been mapped to C-d (that's why I 
   suspected this required some sort of keymap wizardry).  While I could 
   live with C-d and Backspace both meaning delete-backward-char,
   I'd really rather have C-d continue to mean "delete forward" like it 
   ought to.

Hm... you got me there.  It sounds like maybe there's a site file
being loaded (in which case you can try the command line option
--no-site-file when you start Emacs, to the annoyance of your
sysadmins) *or* maybe you've just had some bad luck at the xmodmap
level if it is your own system.  In any event, you can try changing
the behavior of the backspace key around using xmodmap (the analogue
of `global-set-key') and xev (the analogue of the help and command
history commands I showed you).  See the man pages.

   2) your syntax doesn't work in my version:  If I try

   (global-set-key "^d" 'backward-delete-char-untabify)

   I get an initialization error "Key sequence ^ d uses invalid prefix 
   characters"

Did you copy the string from the *Command History* buffer?  You don't
want an asciicircum and a "d" -- you want the "control d character".
You can insert this character without going through the
help/command-history hoops just by pressing C-q C-d.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: keymap problem
       [not found]       ` <mailman.4492.1111343289.32256.help-gnu-emacs@gnu.org>
@ 2005-03-20 19:40         ` no spam
  2005-03-20 19:54           ` Joe Corneli
       [not found]           ` <mailman.4498.1111349806.32256.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: no spam @ 2005-03-20 19:40 UTC (permalink / raw)


Thanks again.  I can run xmodmap and xev on my laptop, but on the 
university's system, I can't.

  xmodmap -pk
xmodmap:  unable to open display ''

and xev I can't find at all.

Although I haven't tried, I suspect that I'm not going to have much 
luck getting an X session across their firewall AND mine.  Is there some 
other way to do this?



Joe Corneli wrote:
>    which means that backspace has already been mapped to C-d (that's why I 
>    suspected this required some sort of keymap wizardry).  While I could 
>    live with C-d and Backspace both meaning delete-backward-char,
>    I'd really rather have C-d continue to mean "delete forward" like it 
>    ought to.
> 
> Hm... you got me there.  It sounds like maybe there's a site file
> being loaded (in which case you can try the command line option
> --no-site-file when you start Emacs, to the annoyance of your
> sysadmins) *or* maybe you've just had some bad luck at the xmodmap
> level if it is your own system.  In any event, you can try changing
> the behavior of the backspace key around using xmodmap (the analogue
> of `global-set-key') and xev (the analogue of the help and command
> history commands I showed you).  See the man pages.
> 
>    2) your syntax doesn't work in my version:  If I try
> 
>    (global-set-key "^d" 'backward-delete-char-untabify)
> 
>    I get an initialization error "Key sequence ^ d uses invalid prefix 
>    characters"
> 
> Did you copy the string from the *Command History* buffer?  You don't
> want an asciicircum and a "d" -- you want the "control d character".
> You can insert this character without going through the
> help/command-history hoops just by pressing C-q C-d.
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: keymap problem
  2005-03-20 19:40         ` no spam
@ 2005-03-20 19:54           ` Joe Corneli
       [not found]           ` <mailman.4498.1111349806.32256.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Joe Corneli @ 2005-03-20 19:54 UTC (permalink / raw)


   Thanks again.  I can run xmodmap and xev on my laptop, but on the 
   university's system, I can't.

   xmodmap -pk
   xmodmap:  unable to open display ''

   and xev I can't find at all.

Sounds bad.  Have you tried putting

 (normal-erase-is-backspace-mode 1)

or 

 (normal-erase-is-backspace-mode -1)

in your .emacs?  That might do what you want, or at least get you part
way there.

   Although I haven't tried, I suspect that I'm not going to have much 
   luck getting an X session across their firewall AND mine.  Is there some 
   other way to do this?

If `normal-erase-is-backspace-mode' doesn't do everything you need,
look at its code and see what you can do using the syntax for
remappings given there (but in your global keymap).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: keymap problem
       [not found]           ` <mailman.4498.1111349806.32256.help-gnu-emacs@gnu.org>
@ 2005-03-20 20:32             ` no spam
  0 siblings, 0 replies; 10+ messages in thread
From: no spam @ 2005-03-20 20:32 UTC (permalink / raw)


(normal-erase-is-backspace-mode -1)  did it!   Thanks so much.



Joe Corneli wrote:
>    Thanks again.  I can run xmodmap and xev on my laptop, but on the 
>    university's system, I can't.
> 
>    xmodmap -pk
>    xmodmap:  unable to open display ''
> 
>    and xev I can't find at all.
> 
> Sounds bad.  Have you tried putting
> 
>  (normal-erase-is-backspace-mode 1)
> 
> or 
> 
>  (normal-erase-is-backspace-mode -1)
> 
> in your .emacs?  That might do what you want, or at least get you part
> way there.
> 
>    Although I haven't tried, I suspect that I'm not going to have much 
>    luck getting an X session across their firewall AND mine.  Is there some 
>    other way to do this?
> 
> If `normal-erase-is-backspace-mode' doesn't do everything you need,
> look at its code and see what you can do using the syntax for
> remappings given there (but in your global keymap).
> 
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Keymap problem
@ 2007-07-15 11:35 lu
  2007-07-16 10:58 ` lu
  0 siblings, 1 reply; 10+ messages in thread
From: lu @ 2007-07-15 11:35 UTC (permalink / raw)
  To: help-gnu-emacs

I use the following code to define a menu named "Pmd" which
have only one menu item named "pmd current buffer".
The menuitem binded to 'pmd-current-buffer.
but the shotcut (C-c p b) does not work,What is the problem?
Thanks.

(defun pmd-minor-mode (&optional arg)
""
(setq pmd-list-entry-keymap (make-keymap))
(use-local-map pmd-list-entry-keymap)
(defvar pmd:map nil
"The pmd keymap.")
(setq pmd:map (make-sparse-keymap))
(define-key pmd:map "\C-cpb" 'pmd-current-buffer)
(easy-menu-define pmd:menu
(list pmd:map pmd-list-entry-keymap)
"pmd menu"
'("Pmd"
[ "pmd current buffer" pmd-current-buffer t ]
)
)

(easy-menu-add pmd:menu pmd:map)
)

(add-hook 'jde-mode-hook (function pmd-minor-mode))

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Keymap problem
  2007-07-15 11:35 Keymap problem lu
@ 2007-07-16 10:58 ` lu
  0 siblings, 0 replies; 10+ messages in thread
From: lu @ 2007-07-16 10:58 UTC (permalink / raw)
  To: help-gnu-emacs


[-- Attachment #1.1: Type: text/plain, Size: 2707 bytes --]

I updated the lisp code to use pmd and added a pmd menu.
The keymap works well too now.

PMD scans Java source code and looks for potential problems like:

    * Possible bugs - empty try/catch/finally/switch statements
    * Dead code - unused local variables, parameters and private methods
    * Suboptimal code - wasteful String/StringBuffer usage
    * Overcomplicated expressions - unnecessary if statements, for loops
      that could be while loops
    * Duplicate code - copied/pasted code means copied/pasted bugs

;;Begin PMD
(add-to-list 'load-path (expand-file-name (concat plugin_path
"/pmd-emacs-0.6")))
(autoload 'pmd-current-buffer "pmd" "PMD Mode" t)
(autoload 'pmd-current-dir "pmd" "PMD Mode" t)
(setq pmd-home (expand-file-name (concat plugin_path
"/pmd-emacs-0.6/pmd-3.9")))
(setq pmd-java-home "java")
(require 'easymenu)
(defvar pmd-minor-mode nil
"")
(make-variable-buffer-local 'pmd-minor-mode)
;(put 'pmd-minor-mode 'permanent-local t)

(setq pmd-list-entry-keymap (make-keymap))
(use-local-map pmd-list-entry-keymap)
(defvar pmd:map nil
"The pmd keymap.")
(setq pmd:map (make-sparse-keymap))
(define-key pmd:map "\C-cpb" 'pmd-current-buffer)
(define-key pmd:map "\C-cpd" 'pmd-current-dir)
(easy-menu-define pmd:menu
(list pmd:map pmd-list-entry-keymap)
"pmd menu"
'("Pmd"
[ "pmd current buffer" pmd-current-buffer t ]
[ "pmd current dir" pmd-current-dir t ]
))

(or (assq 'pmd-minor-mode minor-mode-map-alist)
(setq minor-mode-map-alist (cons (cons 'pmd-minor-mode pmd:map)
minor-mode-map-alist)))

(defun pmd-minor-mode (&optional arg)
""
(progn
(setq pmd-minor-mode (if (null arg) t (car arg)))
(if pmd-minor-mode
(progn
(easy-menu-add pmd:menu pmd:map)
))
pmd-minor-mode
)
)
(add-hook 'jde-mode-hook (function pmd-minor-mode))
;;End pmd


lu@luxdo.jp wrote:
> I use the following code to define a menu named "Pmd" which
> have only one menu item named "pmd current buffer".
> The menuitem binded to 'pmd-current-buffer.
> but the shotcut (C-c p b) does not work,What is the problem?
> Thanks.
>
> (defun pmd-minor-mode (&optional arg)
> ""
> (setq pmd-list-entry-keymap (make-keymap))
> (use-local-map pmd-list-entry-keymap)
> (defvar pmd:map nil
> "The pmd keymap.")
> (setq pmd:map (make-sparse-keymap))
> (define-key pmd:map "\C-cpb" 'pmd-current-buffer)
> (easy-menu-define pmd:menu
> (list pmd:map pmd-list-entry-keymap)
> "pmd menu"
> '("Pmd"
> [ "pmd current buffer" pmd-current-buffer t ]
> )
> )
>
> (easy-menu-add pmd:menu pmd:map)
> )
>
> (add-hook 'jde-mode-hook (function pmd-minor-mode))
>
>
>
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
>
>   


[-- Attachment #1.2: Type: text/html, Size: 3893 bytes --]

[-- Attachment #2: Type: text/plain, Size: 152 bytes --]

_______________________________________________
help-gnu-emacs mailing list
help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-07-16 10:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-15 11:35 Keymap problem lu
2007-07-16 10:58 ` lu
  -- strict thread matches above, loose matches on Subject: below --
2005-03-20  5:43 keymap problem no spam
2005-03-20 16:14 ` Joe Corneli
2005-03-20 16:16   ` Joe Corneli
     [not found]   ` <mailman.4482.1111337221.32256.help-gnu-emacs@gnu.org>
2005-03-20 17:47     ` no spam
2005-03-20 18:11       ` Joe Corneli
     [not found]       ` <mailman.4492.1111343289.32256.help-gnu-emacs@gnu.org>
2005-03-20 19:40         ` no spam
2005-03-20 19:54           ` Joe Corneli
     [not found]           ` <mailman.4498.1111349806.32256.help-gnu-emacs@gnu.org>
2005-03-20 20:32             ` no spam

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.