Skip to content

Commit

Permalink
fixed ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Bin committed Dec 7, 2024
1 parent 7fc763a commit e82368a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Here is complete setup you could insert into =.emacs==,
;; ignore files whose name match certain glob pattern
(setq-local ffip-ignore-filenames '("*.bmp" "*.jpg"))
;; exclude `dist/' directory
(add-to-list 'ffip-prune-patterns "*/dist"))
(push "*/dist" ffip-prune-patterns))
;; insert more WHEN statements below this line for other projects
)
;; most major modes inherit from prog-mode, so below line is enough
Expand Down
39 changes: 17 additions & 22 deletions find-file-in-project.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;;; find-file-in-project.el --- Find file/directory and review Diff/Patch/Commit efficiently -*- coding: utf-8 -*-
;;; find-file-in-project.el --- Find file/directory and review Diff/Patch/Commit efficiently -*- lexical-binding: t -*-

;; Copyright (C) 2006-2009, 2011-2012, 2015-2018
;; Phil Hagelberg, Doug Alcorn, Will Farrington, Chen Bin
Expand Down Expand Up @@ -788,7 +788,6 @@ If KEYWORD is list, it's the list of file names.
IF FIND-DIRECTORY-P is t, we are searching directories, else files."
(let* ((default-directory (ffip-get-project-root-directory))
(cmd (ffip-create-shell-command keyword find-directory-p))
(fd-file-pattern (concat "^" (mapconcat 'ffip-glob-to-regex ffip-patterns "\\|") "$"))
(collection (funcall ffip-project-search-function cmd))
rlt)

Expand Down Expand Up @@ -852,7 +851,7 @@ After opening the file, forward LNUM lines."
If OPEN-ANOTHER-WINDOW is t, the results are displayed in a new window.
If FIND-DIRECTORY-P is t, only search directories. FN is callback.
This function is the API to find files."
(let* (cands lnum file)
(let (cands lnum)
;; extract line num if exists
(when (and keyword (stringp keyword)
(string-match "^\\(.*\\):\\([0-9]+\\):?$" keyword))
Expand Down Expand Up @@ -921,8 +920,7 @@ Please note N is zero originated."
rlt)
(cond
((region-active-p)
(setq ffip-filename-history (add-to-list 'ffip-filename-history
(ffip--read-selected)))
(push (ffip--read-selected) ffip-filename-history)
(setq rlt (ffip--read-selected)))
(t
(setq rlt (read-from-minibuffer hint nil nil nil 'ffip-filename-history))))
Expand All @@ -939,7 +937,7 @@ See (info \"(Emacs) Directory Variables\") for details."
(concat (file-name-as-directory root) ".dir-locals.el"))))
(when file
(with-temp-buffer
(let ((print-level nil) (print-length nil) sexp (rlt '(a)))
(let ((print-level nil) (print-length nil) sexp)
(cond
;; modify existing .dir-locals.el
((file-exists-p file)
Expand All @@ -956,13 +954,13 @@ See (info \"(Emacs) Directory Variables\") for details."
(if (assoc 'ffip-project-root sub-sexp)
(setq new-sub-sexp (delete (assoc 'ffip-project-root sub-sexp) sub-sexp))
(setq new-sub-sexp sub-sexp))
(add-to-list 'new-sub-sexp (ffip--prepare-root-data-for-project-file root) t)
(push (ffip--prepare-root-data-for-project-file root) new-sub-sexp)
;; update sexp
(setq sexp (delete sub-sexp sexp))
(add-to-list 'sexp new-sub-sexp))
(push new-sub-sexp sexp))
(t
;; add `(nil (ffip-project-root . "path/file"))'
(add-to-list 'sexp (list nil (ffip--prepare-root-data-for-project-file root))))))
(push (list nil (ffip--prepare-root-data-for-project-file root)) sexp))))
))
(t
;; a new .dir-locals.el
Expand Down Expand Up @@ -1108,8 +1106,7 @@ If OPEN-ANOTHER-WINDOW is not nil, the file will be opened in new window."
"Insert contents of file in current buffer.
The file name is selected interactively from candidates in project."
(interactive)
(let* ((cands (ffip-project-search (ffip-read-keyword)))
root)
(let* ((cands (ffip-project-search (ffip-read-keyword))))
(when (> (length cands) 0)
(ffip-completing-read (ffip-hint)
cands
Expand Down Expand Up @@ -1394,38 +1391,36 @@ If NUM is not nil, the corresponding backend is executed directly."
(i 0))
;; format backend descriptions
(dolist (b ffip-diff-backends)
(add-to-list 'descriptions
(format "%s: %s"
i
(ffip-backend-description b)) t)
(push (format "%s: %s" i (ffip-backend-description b)) descriptions)
(setq i (+ 1 i)))
(ffip-completing-read
"Run diff backend: "
descriptions
(nreverse descriptions)
(lambda (file)
(if (string-match "^\\([0-9]+\\): " file)
(ffip-show-diff-internal (string-to-number (match-string 1 file))))))))))

;;;###autoload
(defalias 'ffip-show-diff 'ffip-show-diff-by-description)

(defadvice read-file-name (around ffip-read-file-name-hack activate)
"Advice `read-file-name'."
(defun ffip-read-file-name-hack (orig-func &rest args)
"Advice `read-file-name' with ORIG-FUNC and ARGS for `ffip-diff-apply-hunk'."
(cond
(ffip-read-file-name-hijacked-p
;; only hack read-file-name once
(setq ffip-read-file-name-hijacked-p nil)
(let* ((args (ad-get-args 0))
(file-name (file-name-nondirectory (nth 2 args)))
(let* ((file-name (file-name-nondirectory (nth 2 args)))
(default-directory (ffip-project-root))
(cands (ffip-project-search file-name))
(rlt (if cands (ffip-completing-read "Files: " cands))))
(message "file-name=%s" file-name)
(when rlt
(setq rlt (file-truename rlt))
(run-hook-with-args 'ffip-diff-apply-hunk-hook rlt)
(setq ad-return-value rlt))))
rlt)))
(t
ad-do-it)))
(apply orig-func args))))
(advice-add 'read-file-name :around #'ffip-read-file-name-hack)

;;;###autoload
(defun ffip-diff-apply-hunk (&optional reverse)
Expand Down

0 comments on commit e82368a

Please sign in to comment.