Skip to content

Commit

Permalink
Remove mbs-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Apr 22, 2024
1 parent 4935006 commit 6e25baf
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions mbs.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@
:group 'tools
:link '(url-link :tag "Repository" "https://github.com/jcs-elpa/mbs"))

(defconst mbs-read-file-name-commands
`(,(or read-file-name-function #'read-file-name-default))
"List of command to detect find file action.")
;;
;;; Externals

(defvar mbs-reading-file-name-p nil
"Return non-nil if reading file name.")
(defvar vertico--candidates)

;;
;;; Util
Expand All @@ -59,29 +57,14 @@
,@body))

;;
;;; Entry

(defun mbs-mode--adv-around (fnc &rest args)
"Advice bind FNC and ARGS."
(let ((mbs-reading-file-name-p t)) (apply fnc args)))

(defun mbs-mode--enable ()
"Enable function `recentf-excl-mode'."
(dolist (command mbs-read-file-name-commands)
(advice-add command :around #'mbs-mode--adv-around)))
;;; Plugins

(defun mbs-mode--disable ()
"Disable function `recentf-excl-mode'."
(dolist (command mbs-read-file-name-commands)
(advice-remove command #'mbs-mode--adv-around)))

;;;###autoload
(define-minor-mode mbs-mode
"Minor mode `mbs-mode'."
:global t
:require 'mbs-mode
:group 'mbs
(if mbs-mode (mbs-mode--enable) (mbs-mode--disable)))
(defun mbs--vertico-read-file-p ()
"Return non-nil when vertico is reading file name."
(when-let (((bound-and-true-p vertico-mode))
(name (car vertico--candidates)))
(or (file-exists-p name)
(file-exists-p (expand-file-name name)))))

;;
;;; Core
Expand All @@ -96,7 +79,7 @@
(defun mbs-reading-file-name-p ()
"Return non-nil if current minibuffer finding file."
(mbs-with-minibuffer-env
(or mbs-reading-file-name-p
(or (mbs--vertico-read-file-p)
(and (not (mbs-M-x-p))
(not (string-empty-p contents))
(ignore-errors (expand-file-name contents))))))
Expand Down

0 comments on commit 6e25baf

Please sign in to comment.