2010-11-12 5 views
2

J'essaie de définir des raccourcis clavier pour utiliser la touche Shift pour surligner le texte. Je pourrais utiliser pc-selection-mode, mais cela n'offre pas toutes les raccourcis clavier que je veux. Par exemple, j'aimerais pouvoir décaler un paragraphe entier en appuyant sur Maj-Ctrl-bas ce que je peux faire dans la plupart des éditeurs de texte MS, mais pc-selection-mode ne vous permet pas de le faire.GNU emacs: paramétrer les raccourcis clavier pour mettre le texte en surbrillance avec la touche majuscule

J'ai trouvé ce website qui a un fichier shift_mark.el que je peux utiliser pour régler toutes les raccourcis clavier que je veux. J'ai mis dans mon fichier .xemacs/init.el pour charger shift_mark.el.

C'est l'erreur:

Warning (initialization): An error occurred while loading `/home/theory/phrkaj/\ 
.xemacs/init.el': 

Wrong type argument: arrayp, (shift right) 

J'ai couru avec Emacs --debug-init pour essayer de trouver le problème. C'est ce que le débogueur est venu avec:

Debugger entered--Lisp error: (wrong-type-argument arrayp (shift right)) 
    signal(wrong-type-argument (arrayp (shift right))) 
    global-set-key((shift right) shift-mark-forward-char) 
    eval-buffer(#<buffer *load*<3>> nil "/home/theory/phrkaj/shift_mark.el" nil t) ; Reading at buffer position 1476 
    load-with-code-conversion("/home/theory/phrkaj/shift_mark.el" "/home/theory/phrkaj/shift_mark.el" nil nil) 
    load("~/shift_mark.el") 
    eval-buffer(#<buffer *load*<2>> nil "/home/theory/phrkaj/.xemacs/init.el" nil t) ; Reading at buffer position 25 
    load-with-code-conversion("/home/theory/phrkaj/.xemacs/init.el" "/home/theory/phrkaj/.xemacs/init.el" nil nil) 
    load("/home/theory/phrkaj/.xemacs/init.el" nil nil t) 
    load-file("/home/theory/phrkaj/.xemacs/init.el") 
    eval-buffer(#<buffer *load*> nil "/home/theory/phrkaj/.emacs" nil t) ; Reading at buffer position 253 
    load-with-code-conversion("/home/theory/phrkaj/.emacs" "/home/theory/phrkaj/.emacs" t t) 
    load("~/.emacs" t t) 
    #[nil "^H\205\264^@ \306=\203^Q^@\307^H\310Q\2027^@ \311=\2033^@\312\307\313\314#\203#^@\315\2027^@\312\307\313\316#\203/^@\317\2027^@\315\2027^@\307^H\320Q^Z\321^S\322\n\321\211#\210^K\321=\203_^@\323\324\325\307^H\326Q!\"^\\322\f\$ 
    command-line() 
    normal-top-level() 

Voici une partie du fichier shift_mark.el qui définit la mise en évidence d'un caractère à l'avant:

(defun shift-mark-forward-char() 
    (interactive) 
    (shift-mark 'forward-char)) 

(global-set-key '(shift right) 'shift-mark-forward-char) 

Toute aide est appréciée.

+0

Quoi version d'Emacs utilisez-vous? Votre message semble incohérent entre GNU Emacs et XEmacs. Aussi, sous XEmacs 21 sans configuration de ma part et avec GNU Emacs 23 avec 'pc-selection-mode',' Ctrl + Shift + Down' fonctionne comme vous le souhaitez. Cela fonctionne-t-il pour vous si vous démarrez 'emacs -q' ou' xemacs -q' (c'est-à-dire sans charger votre fichier de configuration)? – Gilles

Répondre

3

Sous GNU Emacs, la clé de liaison devrait ressembler à

(global-set-key [(shift right)] 'shift-mark-forward-char) 

([…] construit un tableau littéral). Mais je soupçonne que vous allez à ce mauvais sens. Utilisez-vous GNU Emacs, XEmacs ou les deux? Quelles versions? Sauf si vous utilisez des versions extrêmement anciennes, pc-selection-mode devrait faire ce que vous voulez sous GNU Emacs, et aucune configuration ne devrait être nécessaire sous XEmacs. Si vous exécutez à la fois GNU Emacs et XEmacs, vous pouvez utiliser le code suivant dans votre .emacs:

(defvar running-xemacs (string-match "XEmacs" emacs-version)) 
(if (not running-xemacs) 
    (pc-selection-mode 1)) 
1

Chvshift-select-modeRET

shift-select-mode is a variable defined in `simple.el'. Its value is nil

Documentation: When non-nil, shifted motion keys activate the mark momentarily.

While the mark is activated in this way, any shift-translated point motion key extends the region, and if Transient Mark mode was off, it is temporarily turned on. Furthermore, the mark will be deactivated by any subsequent point motion key that was not shift-translated, or by any action that normally deactivates the mark in Transient Mark mode.

See `this-command-keys-shift-translated' for the meaning of shift-translation.

You can customize this variable.

Cette variable a été introduite dans GNU Emacs 23.1:

** Temporarily active regions

* The new variable shift-select-mode, non-nil by default, controls shift-selection. When Shift Select mode is on, shift-translated motion keys (e.g. S-left and S-down) activate and extend a temporary region, similar to mouse-selection.

* Temporarily active regions, created using shift-selection or mouse-selection, are not necessarily deactivated in the next command. They are only deactivated after point motion commands that are not shift-translated, or after commands that would ordinarily deactivate the mark in Transient Mark mode (e.g., any command that modifies the buffer).

Questions connexes