2013-05-08 38 views
1

Aquamacs24和Emacs-Trunk的最新夜間版本的默認行爲看起來與我習慣的功能不同 - 也就是說,command + shift + right或command + shift +向左跳到視線的開始或結束處,而不選擇區域。相反,必須通過移動shift + left或shift + right或Ctrl + SPC來激活標記,然後轉到視覺線的末端或開始處來設置標記。換句話說,這是一個兩步走的方法,需要結合到一舉兩得。選擇以字包裝的視覺線的開始/結尾

下面的代碼幾乎可以做我正在尋找的東西,除了我希望選擇自動取消,如果我改變主意並釋放shift鍵並移動箭頭鍵。代碼現在寫入的方式保持選擇模式活動,並且不會取消,除非我使用Ctrl + g。

任何人都可以請建議修改我的代碼或其他方式來實現所需的行爲嗎?

(defun beginning-of-visual-line (&optional n) 
    "Move point to the beginning of the current line. 
If `word-wrap' is nil, we move to the beginning of the buffer 
line (as in `beginning-of-line'); otherwise, point is moved to 
the beginning of the visual line." 
    (interactive) 
    (if word-wrap 
     (progn 
    (if (and n (/= n 1)) 
     (vertical-motion (1- n)) 
     (vertical-motion 0)) 
    (skip-read-only-prompt)) 
    (beginning-of-line n))) 


(defun end-of-visual-line (&optional n) 
    "Move point to the end of the current line. 
If `word-wrap' is nil, we move to the end of the line (as in 
`beginning-of-line'); otherwise, point is moved to the end of the 
visual line." 
    (interactive) 
    (if word-wrap 
     (unless (eobp) 
    (progn 
     (if (and n (/= n 1)) 
      (vertical-motion (1- n)) 
     (vertical-motion 1)) 
     (skip-chars-backward " \r\n" (- (point) 1)))) 
    (end-of-line n))) 


(defun command-shift-right() 
    "" 
    (interactive) ;; this is a command (i.e. can be interactively used) 
    (when (not (region-active-p)) ;; if the region is not active... 
    (push-mark (point) t t))  ;; ... set the mark and activate it 
    (end-of-visual-line)) ;; move point defined 


(defun command-shift-left() 
    "" 
    (interactive) ;; this is a command (i.e. can be interactively used) 
    (when (not (region-active-p)) ;; if the region is not active... 
    (push-mark (point) t t))  ;; ... set the mark and activate it 
    (beginning-of-visual-line)) ;; move point defined 
+0

我不知道Aquamacs,但至少在Emacs中,默認的'shift-select-mode'行爲似乎完全是你想要的行爲,只是它沒有提供你提到的特定的鍵綁定。 – Stefan 2013-05-08 16:47:34

回答

2

Emacs中內置了支持shift-select-mode:只使用在功能(interactive "^")當具有換擋觸發他們會選擇。

+0

你修好了!!!!!非常感謝你 !!!!! :) – lawlist 2013-05-08 17:08:42

相關問題