Skip to content

Commit 756f616

Browse files
author
Chen Bin
committed
user can select file name from hunk
1 parent aa55660 commit 756f616

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

‎README.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Execute backend from =ffip-diff-backends=.
123123

124124
The output of backend execution is in [[http://www.gnu.org/software/diffutils/manual/html_node/Unified-Format.html][Unified Diff Format]] and is inserted into =*ffip-diff*= buffer where you can press =o=, =C-c C-c=, =ENTER= , =M-x ffip-diff-find-file= to open the corresponding file.
125125

126-
=ffip-diff-find-file-before-hook= is called before =M-x ffip-diff-find-file=.
126+
=ffip-diff-find-file-before-hook= is called in =ffip-diff-find-file=. Two file names are passed to it as parameters. One name is returned by the hook as the file searching keyword.
127127

128128
For example, you can =M-x ffip-show-diff= to view the git commit and open file inside patch.
129129

‎find-file-in-project.el

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Copyright (C) 2006-2009, 2011-2012, 2015-2018
44
;; Phil Hagelberg, Doug Alcorn, Will Farrington, Chen Bin
55
;;
6-
;; Version: 6.1.1
6+
;; Version: 6.1.2
77
;; Author: Phil Hagelberg, Doug Alcorn, and Will Farrington
88
;; Maintainer: Chen Bin <chenbin.sh@gmail.com>
99
;; URL: https://github.com/redguardtoo/find-file-in-project
@@ -121,7 +121,9 @@
121121
;; buffer to open corresponding file. Please note some backends assume that the git cli program
122122
;; is added into environment variable PATH.
123123
;;
124-
;; `ffip-diff-find-file-before-hook' is called before `ffip-diff-find-file'.
124+
;; `ffip-diff-find-file-before-hook' is called in `ffip-diff-find-file'.
125+
;; Two file names are passed to it as parameters. One name is returned by the hook
126+
;; as the file searching keyword.
125127
;;
126128
;; `ffip-diff-apply-hunk' applies current hunk in `diff-mode' (please note
127129
;; `ffip-diff-mode' inherits from `diff-mode') to the target.
@@ -1252,6 +1254,7 @@ If OPEN-ANOTHER-WINDOW is not nil, the file will be opened in new window."
12521254
(setq keyword (nth 0 files))
12531255
(when ffip-diff-find-file-by-file-name-p
12541256
(setq keyword (file-name-nondirectory keyword)))
1257+
12551258
(ffip-find-files keyword
12561259
open-another-window
12571260
nil
@@ -1261,15 +1264,18 @@ If OPEN-ANOTHER-WINDOW is not nil, the file will be opened in new window."
12611264
(ffip--forward-line ,blnum))))
12621265

12631266
(t
1264-
(run-hook-with-args 'ffip-diff-find-file-before-hook)
1265-
;; pick a file name from A and B
1266-
(setq keyword (cond
1267-
((string= (nth 0 files) "null")
1268-
(nth 1 files))
1269-
(t
1270-
(nth 0 files))))
1267+
(unless (setq keyword (run-hook-with-args 'ffip-diff-find-file-before-hook
1268+
(nth 0 files)
1269+
(nth 1 files)))
1270+
;; pick a file name from A and B
1271+
(setq keyword (cond
1272+
((string= (nth 0 files) "null")
1273+
(nth 1 files))
1274+
(t
1275+
(nth 0 files)))))
12711276
(when ffip-diff-find-file-by-file-name-p
12721277
(setq keyword (file-name-nondirectory keyword)))
1278+
12731279
(ffip-find-files keyword
12741280
open-another-window
12751281
nil

‎pkg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
name=find-file-in-project
3-
version=6.1.1
3+
version=6.1.2
44
pkg=$name-$version
55
mkdir $pkg
66
cp *.el $pkg

0 commit comments

Comments
 (0)