Unshifted characters in Emacs

I need a minor mode that allows shifted characters on numeric keys to be accessed in a different way (and numbers that should then be shifted). This seems to be useful with Perl code ($, @,%, etc.). Ideally, there would be a key to switch this mode. Sort like caplock, but only for numeric keys.

Is there such a regime?

+6
source share
3 answers

One way to throw your own would be something like this:

(define-minor-mode snoopy-mode "Toggle snoopy mode. With no argument, this command toggles the mode. Non-null prefix argument turns on the mode. Null prefix argument turns off the mode." ;; The initial value. nil ;; The indicator for the mode line. " Snoopy" ;; The minor mode bindings. '(("1" . (lambda () (interactive) (insert-char ?! 1))) ("!" . (lambda () (interactive) (insert-char ?1 1))) ;;etc )) 

See background modes and keyboard layouts .

+9
source

Many thanks to jaybee for the answer. Here's an extended definition for all numbers:

 (define-minor-mode shifted-numbers-mode "Toggle shifted numbers mode." nil " shifted" '(("1" . (lambda () (interactive) (insert-char ?! 1))) ("2" . (lambda () (interactive) (insert-char ?@ 1))) ("3" . (lambda () (interactive) (insert-char ?# 1))) ("4" . (lambda () (interactive) (insert-char ?$ 1))) ("5" . (lambda () (interactive) (insert-char ?% 1))) ("6" . (lambda () (interactive) (insert-char ?^ 1))) ("7" . (lambda () (interactive) (insert-char ?& 1))) ("8" . (lambda () (interactive) (insert-char ?* 1))) ("9" . (lambda () (interactive) (insert-char ?( 1))) ("0" . (lambda () (interactive) (insert-char ?) 1))) ("!" . (lambda () (interactive) (insert-char ?1 1))) ("@" . (lambda () (interactive) (insert-char ?2 1))) ("#" . (lambda () (interactive) (insert-char ?3 1))) ("$" . (lambda () (interactive) (insert-char ?4 1))) ("%" . (lambda () (interactive) (insert-char ?5 1))) ("^" . (lambda () (interactive) (insert-char ?6 1))) ("&" . (lambda () (interactive) (insert-char ?7 1))) ("*" . (lambda () (interactive) (insert-char ?8 1))) ("(" . (lambda () (interactive) (insert-char ?9 1))) (")" . (lambda () (interactive) (insert-char ?0 1))))) 

In Perl, parentheses are often more common than parentheses, so you might also want to:

 ("[" . (lambda () (interactive) (insert-char ?{ 1))) ("]" . (lambda () (interactive) (insert-char ?} 1))) ("{" . (lambda () (interactive) (insert-char ?[ 1))) ("}" . (lambda () (interactive) (insert-char ?] 1))) 
+5
source

This is not a complete solution, but my friend wrote a minor mode that automatically inserts a dash or underline depending on the context: Smart-Dash mode

+1
source

Source: https://habr.com/ru/post/890045/


All Articles