Replaced horrible magit-info with nice Item abstraction.

This commit is contained in:
Marius Vollmer 2008-08-21 02:19:58 +03:00
parent e54ab875e3
commit 51c54a329e

357
magit.el
View file

@ -150,7 +150,7 @@ Many Magit faces inherit from this one by default."
(defun magit-get-top-dir (cwd) (defun magit-get-top-dir (cwd)
(let* ((cwd (expand-file-name cwd)) (let* ((cwd (expand-file-name cwd))
(magit-dir (magit-shell "cd '%s' && git rev-parse --git-dir 2>/dev/null" (magit-dir (magit-shell "cd '%s' && git rev-parse --git-dir 2>/dev/null"
cwd))) cwd)))
(if magit-dir (if magit-dir
(file-name-as-directory (or (file-name-directory magit-dir) cwd)) (file-name-as-directory (or (file-name-directory magit-dir) cwd))
nil))) nil)))
@ -180,33 +180,6 @@ Many Magit faces inherit from this one by default."
;;; Highlighting ;;; Highlighting
(defvar magit-highlight-overlay nil)
(defvar magit-highlighted-info nil)
(defun magit-highlight-item ()
(let ((info (get-text-property (point) 'magit-info)))
(cond ((not (eq info magit-highlighted-info))
(setq magit-highlighted-info info)
(if (not magit-highlight-overlay)
(let ((ov (make-overlay 1 1)))
(overlay-put ov 'face 'magit-item-highlight)
(setq magit-highlight-overlay ov)))
(cond ((not info)
(delete-overlay magit-highlight-overlay))
((or (eq (car info) 'hunk))
(move-overlay magit-highlight-overlay
(elt info 3) (elt info 4)
(current-buffer)))
((or (eq (car info) 'diff))
(move-overlay magit-highlight-overlay
(elt info 1) (elt info 2)
(current-buffer)))
(t
(move-overlay magit-highlight-overlay
(line-beginning-position)
(line-beginning-position 2)
(current-buffer))))))))
;;; Revisions and ranges ;;; Revisions and ranges
@ -273,6 +246,42 @@ Many Magit faces inherit from this one by default."
(defun magit-default-rev () (defun magit-default-rev ()
(magit-commit-at-point t)) (magit-commit-at-point t))
;;; Items
(defstruct magit-item
type beginning ending info)
(defun magit-markup-item (beg end type info &optional active-beg active-end)
(let ((item (make-magit-item :type type
:beginning beg
:ending end
:info info)))
(put-text-property (or active-beg beg) (or active-end end)
'magit-item item)
item))
(defun magit-get-item ()
(get-text-property (point) 'magit-item))
(defvar magit-highlight-overlay nil)
(defvar magit-highlighted-item nil)
(defun magit-highlight-item ()
(let ((item (magit-get-item)))
(when (not (eq item magit-highlighted-item))
(setq magit-highlighted-item item)
(if (not magit-highlight-overlay)
(let ((ov (make-overlay 1 1)))
(overlay-put ov 'face 'magit-item-highlight)
(setq magit-highlight-overlay ov)))
(if item
(move-overlay magit-highlight-overlay
(magit-item-beginning item)
(magit-item-ending item)
(current-buffer))
(delete-overlay magit-highlight-overlay)))))
;;; Sections ;;; Sections
(defun magit-insert-section (section title washer cmd &rest args) (defun magit-insert-section (section title washer cmd &rest args)
@ -301,7 +310,7 @@ Many Magit faces inherit from this one by default."
(<= (length prefix) (length section)) (<= (length prefix) (length section))
(equal prefix (subseq section 0 (length prefix))))) (equal prefix (subseq section 0 (length prefix)))))
(defun magit-mark-subsection (beg end subsection level) (defun magit-markup-subsection (beg end subsection level)
(let* ((section (get-text-property beg 'magit-section)) (let* ((section (get-text-property beg 'magit-section))
(new (append (magit-section-head section level) (new (append (magit-section-head section level)
(list subsection)))) (list subsection))))
@ -424,13 +433,13 @@ Many Magit faces inherit from this one by default."
(define-key map (kbd "3") 'magit-jump-to-staged) (define-key map (kbd "3") 'magit-jump-to-staged)
(define-key map (kbd "4") 'magit-jump-to-unpushed) (define-key map (kbd "4") 'magit-jump-to-unpushed)
(define-key map (kbd "g") 'magit-status) (define-key map (kbd "g") 'magit-status)
(define-key map (kbd "s") 'magit-stage-thing-at-point) (define-key map (kbd "s") 'magit-stage-item)
(define-key map (kbd "S") 'magit-stage-all) (define-key map (kbd "S") 'magit-stage-all)
(define-key map (kbd "u") 'magit-unstage-thing-at-point) (define-key map (kbd "u") 'magit-unstage-item)
(define-key map (kbd "U") 'magit-unstage-all) (define-key map (kbd "U") 'magit-unstage-all)
(define-key map (kbd "i") 'magit-ignore-thing-at-point) (define-key map (kbd "i") 'magit-ignore-item)
(define-key map (kbd "?") 'magit-describe-thing-at-point) (define-key map (kbd "?") 'magit-describe-item)
(define-key map (kbd ".") 'magit-mark-thing-at-point) (define-key map (kbd ".") 'magit-mark-item)
(define-key map (kbd "=") 'magit-diff-with-mark) (define-key map (kbd "=") 'magit-diff-with-mark)
(define-key map (kbd "l") 'magit-log-head) (define-key map (kbd "l") 'magit-log-head)
(define-key map (kbd "L") 'magit-log) (define-key map (kbd "L") 'magit-log)
@ -440,7 +449,7 @@ Many Magit faces inherit from this one by default."
(define-key map (kbd "v") 'magit-revert-commit) (define-key map (kbd "v") 'magit-revert-commit)
(define-key map (kbd "x") 'magit-reset-head) (define-key map (kbd "x") 'magit-reset-head)
(define-key map (kbd "X") 'magit-reset-working-tree) (define-key map (kbd "X") 'magit-reset-working-tree)
(define-key map (kbd "RET") 'magit-visit-thing-at-point) (define-key map (kbd "RET") 'magit-visit-item)
(define-key map (kbd "b") 'magit-checkout) (define-key map (kbd "b") 'magit-checkout)
(define-key map (kbd "B") 'magit-create-branch) (define-key map (kbd "B") 'magit-create-branch)
(define-key map (kbd "m") 'magit-manual-merge) (define-key map (kbd "m") 'magit-manual-merge)
@ -490,39 +499,45 @@ Please see the manual for a complete description of Magit.
;;; Status ;;; Status
(defun magit-wash-other-files (status) (defun magit-wash-untracked-files (status)
(goto-char (point-min)) (goto-char (point-min))
(let ((seq 0)) (let ((seq 0))
(while (not (eobp)) (while (not (eobp))
(let ((filename (buffer-substring (point) (line-end-position)))) (let ((filename (buffer-substring-no-properties
(point) (line-end-position))))
(cond ((not (string= filename "")) (cond ((not (string= filename ""))
(magit-mark-subsection (line-beginning-position) (magit-markup-subsection (line-beginning-position)
(line-beginning-position 2) (line-beginning-position 2)
seq 1) seq 1)
(magit-put-line-property 'face '(:foreground "red")) (magit-put-line-property 'face '(:foreground "red"))
(magit-put-line-property 'magit-info (magit-markup-item (line-beginning-position)
(list 'other-file filename)) (line-beginning-position 2)
'untracked-file filename)
(setq seq (+ seq 1))))) (setq seq (+ seq 1)))))
(forward-line) (forward-line)
(beginning-of-line)))) (beginning-of-line))))
(defun magit-wash-diff-propertize-diff (head-seq head-beg head-end) (defun magit-wash-diff-markup-diff (head-seq head-beg head-end)
(let ((head-end (or head-end (point)))) (let ((head-end (or head-end (point))))
(when head-beg (when head-beg
(put-text-property head-beg head-end (magit-markup-item head-beg (point)
'magit-info (list 'diff 'diff nil
head-beg (point))) head-beg head-end)
(magit-mark-subsection head-beg head-end head-seq 1)))) (magit-markup-subsection head-beg head-end head-seq 1))))
(defun magit-wash-diff-propertize-hunk (head-seq hunk-seq (defun magit-hunk-item-head-beg (item)
head-beg head-end hunk-beg) (car (magit-item-info item)))
(defun magit-hunk-item-head-end (item)
(cadr (magit-item-info item)))
(defun magit-wash-diff-markup-hunk (head-seq hunk-seq
head-beg head-end hunk-beg)
(when hunk-beg (when hunk-beg
(put-text-property hunk-beg (point) (magit-markup-item hunk-beg (point)
'magit-info (list 'hunk 'hunk (list head-beg head-end))
head-beg head-end (magit-markup-subsection hunk-beg (point) head-seq 1)
hunk-beg (point))) (magit-markup-subsection hunk-beg (point) hunk-seq 2)))
(magit-mark-subsection hunk-beg (point) head-seq 1)
(magit-mark-subsection hunk-beg (point) hunk-seq 2)))
(defun magit-wash-diff (status) (defun magit-wash-diff (status)
(goto-char (point-min)) (goto-char (point-min))
@ -537,9 +552,9 @@ Please see the manual for a complete description of Magit.
(point) (min (+ (point) n-files) (point-max))))) (point) (min (+ (point) n-files) (point-max)))))
(cond ((looking-at "^diff") (cond ((looking-at "^diff")
(magit-put-line-property 'face 'magit-diff-file-header) (magit-put-line-property 'face 'magit-diff-file-header)
(magit-wash-diff-propertize-diff head-seq head-beg head-end) (magit-wash-diff-markup-diff head-seq head-beg head-end)
(magit-wash-diff-propertize-hunk head-seq hunk-seq (magit-wash-diff-markup-hunk head-seq hunk-seq
head-beg head-end hunk-beg) head-beg head-end hunk-beg)
(setq head-seq (+ head-seq 1)) (setq head-seq (+ head-seq 1))
(setq head-beg (point)) (setq head-beg (point))
(setq head-end nil) (setq head-end nil)
@ -550,8 +565,8 @@ Please see the manual for a complete description of Magit.
(setq n-files (- (length (match-string 0)) 1)) (setq n-files (- (length (match-string 0)) 1))
(if (null head-end) (if (null head-end)
(setq head-end (point))) (setq head-end (point)))
(magit-wash-diff-propertize-hunk head-seq hunk-seq (magit-wash-diff-markup-hunk head-seq hunk-seq
head-beg head-end hunk-beg) head-beg head-end hunk-beg)
(setq hunk-seq (+ hunk-seq 1)) (setq hunk-seq (+ hunk-seq 1))
(setq hunk-beg (point))) (setq hunk-beg (point)))
((looking-at "^ ") ((looking-at "^ ")
@ -562,9 +577,9 @@ Please see the manual for a complete description of Magit.
(magit-put-line-property 'face 'magit-diff-del)))) (magit-put-line-property 'face 'magit-diff-del))))
(forward-line) (forward-line)
(beginning-of-line)) (beginning-of-line))
(magit-wash-diff-propertize-diff head-seq head-beg head-end) (magit-wash-diff-markup-diff head-seq head-beg head-end)
(magit-wash-diff-propertize-hunk head-seq hunk-seq (magit-wash-diff-markup-hunk head-seq hunk-seq
head-beg head-end hunk-beg))) head-beg head-end hunk-beg)))
(defun magit-update-status (buf) (defun magit-update-status (buf)
(with-current-buffer buf (with-current-buffer buf
@ -596,8 +611,8 @@ Please see the manual for a complete description of Magit.
(insert (apply 'format "Rebasing: %s (%s of %s)\n" rebase)))) (insert (apply 'format "Rebasing: %s (%s of %s)\n" rebase))))
(insert "\n") (insert "\n")
(magit-insert-section 'untracked (magit-insert-section 'untracked
"Untracked files:" 'magit-wash-other-files "Untracked files:" 'magit-wash-untracked-files
"git" "ls-files" "--others" "--exclude-standard") "git" "ls-files" "--others" "--exclude-standard")
(magit-insert-section 'unstaged (magit-insert-section 'unstaged
"Unstaged changes:" 'magit-wash-diff "Unstaged changes:" 'magit-wash-diff
"git" "diff") "git" "diff")
@ -640,28 +655,32 @@ Please see the manual for a complete description of Magit.
;;; Staging ;;; Staging
(defun magit-write-diff-patch (info file) (defun magit-write-hunk-item-patch (info file)
(write-region (elt info 1) (elt info 2) file)) (write-region (magit-hunk-item-head-beg item)
(magit-hunk-item-head-end item)
file)
(write-region (magit-item-beginning item)
(magit-item-ending item)
file
t))
(defun magit-write-hunk-patch (info file) (defun magit-hunk-item-is-conflict-p (item)
(write-region (elt info 1) (elt info 2) file)
(write-region (elt info 3) (elt info 4) file t))
(defun magit-hunk-is-conflict-p (info)
(save-excursion (save-excursion
(goto-char (elt info 1)) (goto-char (magit-hunk-item-head-beg item))
(looking-at "^diff --cc"))) (looking-at "^diff --cc")))
(defun magit-diff-conflict-file (info) (defun magit-diff-item-conflict-file (item)
(save-excursion (save-excursion
(goto-char (elt info 1)) (goto-char (magit-item-beginning item))
(if (looking-at "^diff --cc +\\(.*\\)$") (if (looking-at "^diff --cc +\\(.*\\)$")
(match-string 1) (match-string 1)
nil))) nil)))
(defun magit-diff-info-file (info) (defun magit-diff-or-hunk-item-file (item)
(save-excursion (save-excursion
(goto-char (elt info 1)) (goto-char (if (eq (magit-item-type item) 'hunk)
(magit-hunk-item-head-beg item)
(magit-item-beginning item)))
(cond ((looking-at "^diff --git a/\\(.*\\) b/\\(.*\\)$") (cond ((looking-at "^diff --git a/\\(.*\\) b/\\(.*\\)$")
(match-string 2)) (match-string 2))
((looking-at "^diff --cc +\\(.*\\)$") ((looking-at "^diff --cc +\\(.*\\)$")
@ -669,23 +688,23 @@ Please see the manual for a complete description of Magit.
(t (t
nil)))) nil))))
(defun magit-diff-info-position (info) (defun magit-diff-or-hunk-item-position (item)
(save-excursion (save-excursion
(cond ((eq (car info) 'hunk) (if (eq (magit-item-type item) 'hunk)
(goto-char (elt info 3)) (goto-char (magit-item-beginning item))
(if (looking-at "@@+ .* \\+\\([0-9]+\\),[0-9]+ @@+") (if (looking-at "@@+ .* \\+\\([0-9]+\\),[0-9]+ @@+")
(parse-integer (match-string 1)) (parse-integer (match-string 1))
nil)) nil)
(t nil)))) nil)))
(defun magit-hunk-target-line (info) (defun magit-hunk-item-target-line (item)
;; XXX - deal with combined diffs ;; XXX - deal with combined diffs
(save-excursion (save-excursion
(beginning-of-line) (beginning-of-line)
(let ((line (line-number-at-pos))) (let ((line (line-number-at-pos)))
(if (looking-at "-") (if (looking-at "-")
(error "Can't visit removed lines.")) (error "Can't visit removed lines."))
(goto-char (elt info 3)) (goto-char (magit-item-beginning item))
(if (not (looking-at "@@+ .* \\+\\([0-9]+\\),[0-9]+ @@+")) (if (not (looking-at "@@+ .* \\+\\([0-9]+\\),[0-9]+ @@+"))
(error "Hunk header not found.")) (error "Hunk header not found."))
(let ((target (parse-integer (match-string 1)))) (let ((target (parse-integer (match-string 1))))
@ -696,34 +715,34 @@ Please see the manual for a complete description of Magit.
(forward-line)) (forward-line))
target)))) target))))
(defun magit-stage-thing-at-point () (defun magit-stage-item ()
"Add the hunk or file under point to the staging area." "Add the item at point to the staging area."
(interactive) (interactive)
(let ((info (get-char-property (point) 'magit-info))) (let ((item (magit-get-item)))
(if info (if item
(case (car info) (case (magit-item-type item)
((other-file) ((untracked-file)
(magit-run "git" "add" (cadr info))) (magit-run "git" "add" (magit-item-info item)))
((hunk) ((hunk)
(if (magit-hunk-is-conflict-p info) (if (magit-hunk-item-is-conflict-p item)
(error (error "Can't stage individual resolution hunks. Please stage the whole file."))
"Can't stage individual resolution hunks. Please stage the whole file.")) (magit-write-hunk-item-patch item ".git/magit-tmp")
(magit-write-hunk-patch info ".git/magit-tmp")
(magit-run "git" "apply" "--cached" ".git/magit-tmp")) (magit-run "git" "apply" "--cached" ".git/magit-tmp"))
((diff) ((diff)
(magit-run "git" "add" (magit-diff-info-file info))))))) (magit-run "git" "add" (magit-diff-or-hunk-item-file item)))))))
(defun magit-unstage-thing-at-point () (defun magit-unstage-item ()
"Remove the hunk under point from the staging area." "Remove the item at point from the staging area."
(interactive) (interactive)
(let ((info (get-char-property (point) 'magit-info))) (let ((item (magit-get-item)))
(if info (if item
(case (car info) (case (magit-item-type item)
((hunk) ((hunk)
(magit-write-hunk-patch info ".git/magit-tmp") (magit-write-hunk-item-patch item ".git/magit-tmp")
(magit-run "git" "apply" "--cached" "--reverse" ".git/magit-tmp")) (magit-run "git" "apply" "--cached" "--reverse" ".git/magit-tmp"))
((diff) ((diff)
(magit-run "git" "reset" "HEAD" (magit-diff-info-file info))))))) (magit-run "git" "reset" "HEAD"
(magit-diffor-hunk-item-file item)))))))
(defun magit-stage-all () (defun magit-stage-all ()
(interactive) (interactive)
@ -739,7 +758,7 @@ Please see the manual for a complete description of Magit.
(interactive (list (magit-read-rev "Switch to" (magit-default-rev)))) (interactive (list (magit-read-rev "Switch to" (magit-default-rev))))
(if rev (if rev
(magit-run "git" "checkout" (magit-rev-to-git rev)))) (magit-run "git" "checkout" (magit-rev-to-git rev))))
(defun magit-read-create-branch-args () (defun magit-read-create-branch-args ()
(let* ((cur-branch (magit-get-current-branch)) (let* ((cur-branch (magit-get-current-branch))
(branch (read-string "Create branch: ")) (branch (read-string "Create branch: "))
@ -787,7 +806,7 @@ Please see the manual for a complete description of Magit.
(if (not info) (if (not info)
(let ((rev (magit-read-rev "Rebase to"))) (let ((rev (magit-read-rev "Rebase to")))
(if rev (if rev
(magit-run "git" "rebase" rev))) (magit-run "git" "rebase" (magit-rev-to-git rev))))
(let ((cursor-in-echo-area t) (let ((cursor-in-echo-area t)
(message-log-max nil)) (message-log-max nil))
(message "Rebase in progress. Abort, Skip, or Continue? ") (message "Rebase in progress. Abort, Skip, or Continue? ")
@ -872,44 +891,46 @@ Please see the manual for a complete description of Magit.
(defun magit-add-log () (defun magit-add-log ()
(interactive) (interactive)
(let* ((fun (save-window-excursion (let ((item (magit-get-item)))
(if (not (and item (eq (magit-item-type item) 'hunk)))
(error "No hunk at point."))
(let ((fun (save-window-excursion
(save-excursion (save-excursion
(magit-visit-thing-at-point) (magit-visit-item)
(add-log-current-defun)))) (add-log-current-defun))))
(file (magit-diff-info-file (get-text-property (point) (file (magit-diff-or-hunk-item-file item)))
'magit-info)))) (magit-log-edit)
(magit-log-edit) (goto-char (point-min))
(goto-char (point-min)) (cond ((not (search-forward-regexp (format "^\\* %s" (regexp-quote file))
(cond ((not (search-forward-regexp (format "^\\* %s" (regexp-quote file)) nil t))
nil t)) ;; No entry for file, create it.
;; No entry for file, create it. (goto-char (point-max))
(goto-char (point-max)) (insert (format "\n* %s (%s): " file fun)))
(insert (format "\n* %s (%s): " file fun))) (t
(t ;; found entry for file, look for fun
;; found entry for file, look for fun (let ((limit (or (search-forward-regexp "^\\* " nil t)
(let ((limit (or (search-forward-regexp "^\\* " nil t) (point-max))))
(point-max)))) (cond ((search-forward-regexp (format "(.*\\<%s\\>.*):"
(cond ((search-forward-regexp (format "(.*\\<%s\\>.*):" (regexp-quote fun))
(regexp-quote fun)) limit t)
limit t) ;; found it, goto end of current entry
;; found it, goto end of current entry (if (search-forward-regexp "^(" limit t)
(if (search-forward-regexp "^(" limit t) (backward-char 2)
(backward-char 2) (goto-char limit)))
(goto-char limit))) (t
(t ;; not found insert new entry
;; not found insert new entry (goto-char limit)
(goto-char limit) (beginning-of-line)
(beginning-of-line) (open-line 1)
(open-line 1) (insert (format "(%s): " fun))))))))))
(insert (format "(%s): " fun)))))))))
;;; Commits ;;; Commits
(defun magit-commit-at-point (&optional nil-ok-p) (defun magit-commit-at-point (&optional nil-ok-p)
(let* ((info (get-text-property (point) 'magit-info)) (let* ((item (magit-get-item))
(commit (and info (commit (and item
(eq (car info) 'commit) (eq (magit-item-type item) 'commit)
(cadr info)))) (magit-item-info item))))
(if nil-ok-p (if nil-ok-p
commit commit
(or commit (or commit
@ -948,7 +969,9 @@ Please see the manual for a complete description of Magit.
(delete-region (match-beginning 0) (match-end 0)) (delete-region (match-beginning 0) (match-end 0))
(goto-char (match-beginning 0)) (goto-char (match-beginning 0))
(fixup-whitespace) (fixup-whitespace)
(magit-put-line-property 'magit-info (list 'commit commit)))) (magit-markup-item (line-beginning-position)
(line-beginning-position 2)
'commit commit)))
(forward-line))) (forward-line)))
(defun magit-log (range) (defun magit-log (range)
@ -1020,13 +1043,14 @@ Please see the manual for a complete description of Magit.
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(goto-char (point-min)) (goto-char (point-min))
(while (not (eobp)) (while (not (eobp))
(let ((info (get-text-property (point) 'magit-info)) (let ((item (get-text-property (point) 'magit-item))
(next-change (or (next-single-property-change (point) (next-change (or (next-single-property-change (point)
'magit-info) 'magit-item)
(point-max)))) (point-max))))
(if (and info (eq (car info) 'commit)) (if (and item (eq (magit-item-type item) 'commit))
(put-text-property (point) next-change (put-text-property (point) next-change
'face (if (equal marked (cadr info)) 'face (if (equal marked
(magit-item-info item))
'(:foreground "red") '(:foreground "red")
nil))) nil)))
(goto-char next-change))))))) (goto-char next-change)))))))
@ -1037,43 +1061,48 @@ Please see the manual for a complete description of Magit.
(if (not (eq (current-buffer) status-buffer)) (if (not (eq (current-buffer) status-buffer))
(magit-refresh-marks-in-buffer status-buffer)))) (magit-refresh-marks-in-buffer status-buffer))))
(defun magit-mark-thing-at-point () (defun magit-mark-item ()
(interactive) (interactive)
(magit-set-marked-object (magit-commit-at-point)) (magit-set-marked-object (magit-commit-at-point))
(magit-refresh-marks)) (magit-refresh-marks))
;;; Miscellaneous ;;; Miscellaneous
(defun magit-ignore-thing-at-point () (defun magit-ignore-item ()
(interactive) (interactive)
(let ((info (get-char-property (point) 'magit-info))) (let ((item (magit-get-item)))
(if info (if item
(case (car info) (case (magit-item-type item)
((other-file) ((untracked-file)
(append-to-file (concat "/" (cadr info) "\n") nil ".gitignore") (append-to-file (concat "/" (magit-item-info item) "\n")
nil ".gitignore")
(magit-update-status (magit-find-status-buffer))))))) (magit-update-status (magit-find-status-buffer)))))))
(defun magit-visit-thing-at-point () (defun magit-visit-item ()
(interactive) (interactive)
(let ((info (get-char-property (point) 'magit-info))) (let ((item (magit-get-item)))
(if info (if item
(case (car info) (case (magit-item-type item)
((other-file) ((untracked-file)
(find-file (cadr info))) (find-file (magit-item-info item)))
((diff hunk) ((diff hunk)
(let ((file (magit-diff-info-file info)) (let ((file (magit-diff-or-hunk-item-file item))
(line (if (eq (car info) 'hunk) (line (if (eq (magit-item-type item) 'hunk)
(magit-hunk-target-line info) (magit-hunk-item-target-line item)
(magit-diff-info-position info)))) (magit-diff-item-position item))))
(find-file file) (find-file file)
(if line (if line
(goto-line line)))) (goto-line line))))
((commit) ((commit)
(magit-show-commit)))))) (magit-show-commit))))))
(defun magit-describe-thing-at-point () (defun magit-describe-item ()
(interactive) (interactive)
(let ((info (get-char-property (point) 'magit-info))) (let ((item (magit-get-item)))
(message "Thing: %s" info))) (message "Item: %s %s-%s %S"
(magit-item-type item)
(magit-item-beginning item)
(magit-item-ending item)
(magit-item-info item))))
(provide 'magit) (provide 'magit)