Show
Ignore:
Timestamp:
04/26/08 12:04:46 (16 years ago)
Author:
gan2
Message:

n, p でポイント上のユーザの次(前)の発言に移動する設定を追加
そのための関数をいくつか定義
前回定義した j, k 用の関数名を変更

Location:
lang/elisp/twittering-mode/branches/gan2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/elisp/twittering-mode/branches/gan2/ChangeLog

    r28 r31  
     12008-04-26  gan2  <gan2.ruby@gmail.com> 
     2 
     3        * twittering-mode.el: n, p でポイント上のユーザの次(前)の発言に移動する設定を追加 
     4        (twittering-goto-next-status): twittering-next-message の名前を変更 
     5        (twittering-get-next-username-face-pos): twittering-next-username-face-pos の名前を変更 
     6        (twittering-goto-previous-status): twittering-previous-message の名前を変更 
     7        (twittering-get-previous-username-face-pos): twittering-previous-username-face-pos の名前を変更 
     8        (twittering-goto-next-status-of-user): ポイント上のユーザの次の発言へ移動する関数を定義 
     9        (twittering-goto-previous-status-of-user): ポイント上のユーザの前の発言へ移動する関数を定義 
     10        (twittering-get-username-at-pos): ポイント上のユーザ名を返す関数を定義 
     11        (twittering-mode-map): n, p でポイント上のユーザの次(前)の発言に移動する設定を追加 
     12 
    1132008-04-25  gan2  <gan2.ruby@gmail.com> 
    214 
  • lang/elisp/twittering-mode/branches/gan2/twittering-mode.el

    r30 r31  
    235235      ;; (define-key km "j" 'next-line) 
    236236      ;; (define-key km "k" 'previous-line) 
    237       (define-key km "j" 'twittering-next-status) 
    238       (define-key km "k" 'twittering-previous-status) 
     237      (define-key km "j" 'twittering-goto-next-status) 
     238      (define-key km "k" 'twittering-goto-previous-status) 
    239239      (define-key km "l" 'forward-char) 
    240240      (define-key km "h" 'backward-char) 
     
    242242      (define-key km "^" 'beginning-of-line-text) 
    243243      (define-key km "$" 'end-of-line) 
     244      (define-key km "n" 'twittering-goto-next-status-of-user) 
     245      (define-key km "p" 'twittering-goto-previous-status-of-user) 
    244246      (define-key km [backspace] 'backward-char) 
    245247      (define-key km "G" 'end-of-buffer) 
     
    939941      (setq twittering-password (read-passwd "twittering-mode: ")))) 
    940942 
    941 (defun twittering-next-status () 
     943(defun twittering-goto-next-status () 
    942944  "Go to next status." 
    943945  (interactive) 
    944946  (let ((pos)) 
    945     (setq pos (twittering-next-username-face-pos (point))) 
     947    (setq pos (twittering-get-next-username-face-pos (point))) 
    946948    (when pos 
    947949      (goto-char pos)))) 
    948950 
    949 (defun twittering-next-username-face-pos (pos) 
     951(defun twittering-get-next-username-face-pos (pos) 
    950952  (interactive) 
    951953  (let ((prop)) 
     
    955957    pos)) 
    956958 
    957 (defun twittering-previous-status () 
     959(defun twittering-goto-previous-status () 
    958960  "Go to previous status." 
    959961  (interactive) 
    960962  (let ((pos)) 
    961     (setq pos (twittering-previous-username-face-pos (point))) 
     963    (setq pos (twittering-get-previous-username-face-pos (point))) 
    962964    (when pos 
    963965      (goto-char pos)))) 
    964966 
    965 (defun twittering-previous-username-face-pos (pos) 
     967(defun twittering-get-previous-username-face-pos (pos) 
    966968  (interactive) 
    967969  (let ((prop)) 
     
    971973    pos)) 
    972974 
     975(defun twittering-goto-next-status-of-user () 
     976  "Go to next status of user." 
     977  (interactive) 
     978  (let ((user-name (twittering-get-username-at-pos (point))) 
     979        (pos (twittering-get-next-username-face-pos (point)))) 
     980    (while (not (equal (twittering-get-username-at-pos pos) user-name)) 
     981      (setq pos (twittering-get-next-username-face-pos pos))) 
     982    (goto-char pos))) 
     983 
     984(defun twittering-goto-previous-status-of-user () 
     985  "Go to previous status of user." 
     986  (interactive) 
     987  (let ((user-name (twittering-get-username-at-pos (point))) 
     988        (pos (twittering-get-previous-username-face-pos (point)))) 
     989    (while (not (equal (twittering-get-username-at-pos pos) user-name)) 
     990      (setq pos (twittering-get-previous-username-face-pos pos))) 
     991    (goto-char pos))) 
     992 
     993(defun twittering-get-username-at-pos (pos) 
     994  (let ((start-pos pos) 
     995        (end-pos)) 
     996    (while (eq (get-text-property start-pos 'face) twittering-username-face) 
     997      (setq start-pos (1- start-pos))) 
     998    (setq start-pos (1+ start-pos)) 
     999    (setq end-pos (next-single-property-change pos 'face)) 
     1000    (buffer-substring start-pos end-pos))) 
     1001 
    9731002(provide 'twittering-mode) 
    9741003;;; twittering.el ends here