1

Aquamacs24 と Emacs-Trunk の最新のナイトリー ビルドのデフォルト動作は、どちらも私が慣れているものとは異なる機能をしているように見えます。リージョンの選択。代わりに、shift+left または shift+right または Ctrl+SPC を移動してマークを設定し、マークをアクティブにしてから、視線の最後または最初に移動する必要があります。言い換えれば、これは 2 段階のアプローチであり、それらを一気に組み合わせる必要があります。

次のコードは、私が探していることをほぼ実行します。ただし、気が変わってシフト キーを放し、矢印キーを移動すると、選択が自動的にキャンセルされるようにする必要があります。コードが現在書かれている方法は、選択モードをアクティブに保ち、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
4

1 に答える 1

2

Emacs には組み込みのサポートがあります。関数でshift-select-mode使用するだけ(interactive "^")で、シフトでトリガーされたときに選択されます。

于 2013-05-08T16:48:31.847 に答える