2011-11-12 17 views
3

見下我可以通過單擊emacs中的linum列來選擇文本嗎?

我的回答下一個段落是在這裏讓機器人快樂

T骨佈雷紹拉布丹豬排,雞腿中的非ullamco魁voluptate鹿肉fugiat臀部薰法無。 Nostrud火腿pariatur,勞工是牛奶duis aliqua elitleberkäse。 Capicola ut豬肉五花肉,肉丸veniam菲力牛排舌頭鼓槌側翼ut proident廣告。 T-bone shankle culpa舌頭nulla dolore biltong,pancetta nostrud ut。 Sed牛肉牛腩肉,牛腩肉。 Culpa帶牛排鍛鍊ea aute肩膀。 Ribeye肩膀夾頭,條形牛排磨碎圓形牛腩牛腩consequat capicola牛肉leberkäse小腿小腿。

+1

,你應該能夠回答; [它不需要任何代表](http://stackoverflow.com/privileges/create-posts)。嘗試點擊「回答你的問題」按鈕。自我回答規則可能已經改變。 – jfs

+2

你可以自我回答,但你需要等待8小時,除非你的代表是> = 100 – sabof

回答

3

這裏是您可以添加到.emacs的代碼
當您單擊邊距並釋放光標時,它會選擇相應的行。
測試了GNU Emacs的23.3

更新:修正錯誤

(defvar *linum-mdown-line* nil) 

(defun line-at-click() 
    (save-excursion 
    (let ((click-y (cdr (cdr (mouse-position)))) 
      (line-move-visual-store line-move-visual)) 
     (setq line-move-visual t) 
     (goto-char (window-start)) 
     (next-line (1- click-y)) 
     (setq line-move-visual line-move-visual-store) 
     ;; If you are using tabbar substitute the next line with 
     ;; (line-number-at-pos)))) 
     (1+ (line-number-at-pos))))) 

(defun md-select-linum() 
    (interactive) 
    (goto-line (line-at-click)) 
    (set-mark (point)) 
    (setq *linum-mdown-line* (line-number-at-pos))) 

(defun mu-select-linum() 
    (interactive) 
    (when *linum-mdown-line* 
    (let (mu-line) 
     (setq mu-line (line-at-click)) 
     (if (> mu-line *linum-mdown-line*) 
      (progn 
      (goto-line *linum-mdown-line*) 
      (set-mark (point)) 
      (goto-line mu-line) 
      (end-of-line)) 
      (progn 
      (goto-line *linum-mdown-line*) 
      (set-mark (line-end-position)) 
      (goto-line mu-line) 
      (beginning-of-line))) 
     (setq *linum-mdown* nil)))) 

(global-set-key (kbd "<left-margin> <down-mouse-1>") 'md-select-linum) 
(global-set-key (kbd "<left-margin> <mouse-1>") 'mu-select-linum) 
(global-set-key (kbd "<left-margin> <drag-mouse-1>") 'mu-select-linum) 
相關問題