Skip to content

Commit

Permalink
tweak: better use of executable-find
Browse files Browse the repository at this point in the history
  • Loading branch information
abougouffa committed May 30, 2023
1 parent 01ddbfc commit a976cab
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion core/me-loaddefs.el
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ so it can be used to save HTML pages or emails to PDF.
When MAIL-MODE-P is non-nil, treat INFILE as a mail.
(fn INFILE &optional MAIL-MODE-P)")
(defvar +single-file-executable (executable-find "single-file") "\
(defvar +single-file-executable "single-file" "\
The executable for \"single-file\" which is used archive HTML pages.")
(custom-autoload '+single-file-executable "../elisp/+io" t)
(autoload '+single-file "../elisp/+io" "\
Expand Down
7 changes: 4 additions & 3 deletions elisp/+binary.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"MinEmacs binary files."
:group 'minemacs)

(defcustom +binary-objdump-executable (executable-find "objdump")
"Path to the executable \"objdump\" utility."
(defcustom +binary-objdump-executable "objdump"
"The \"objdump\" command."
:group 'minemacs-binary
:type 'string)
:type '(choice file string))

(defcustom +binary-objdump-enable t
"Enable or disable disassembling suitable files with objdump."
Expand All @@ -34,6 +34,7 @@
(when-let* ((file (buffer-file-name (or buffer (current-buffer))))
(file (file-truename file)))
(and +binary-objdump-executable
(executable-find +binary-objdump-executable)
(file-exists-p file)
(not (file-directory-p file))
(not (zerop (file-attribute-size (file-attributes file))))
Expand Down
4 changes: 2 additions & 2 deletions elisp/+io.el
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ When MAIL-MODE-P is non-nil, treat INFILE as a mail."
"An error occurred, cannot create the PDF!")))))

;;;###autoload
(defcustom +single-file-executable (executable-find "single-file")
(defcustom +single-file-executable "single-file"
"The executable for \"single-file\" which is used archive HTML pages.")

;;;###autoload
(defun +single-file (url out-file)
"Save URL into OUT-FILE as a standalone HTML file."
(if (and +single-file-executable (executable-find +single-file-executable))
(if (executable-find +single-file-executable)
(make-process
:name "single-file-cli"
:buffer "*single-file*"
Expand Down
18 changes: 11 additions & 7 deletions modules/me-robot.el
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,20 @@
"MinEmacs robotics stuff."
:group 'minemacs)

(defcustom +ros-mcap-command (or (executable-find "mcap") (executable-find "mcap-cli"))
(defcustom +ros-mcap-command "mcap-cli"
"ROS 2 MCAP command."
:group 'minemacs-robot)
:group 'minemacs-robot
:type '(choice file string))

(defcustom +ros-rosbag-command (executable-find "rosbag")
(defcustom +ros-rosbag-command "rosbag"
"ROS 1 \"rosbag\" command."
:group 'minemacs-robot)
:group 'minemacs-robot
:type '(choice file string))

(defcustom +ros-ros2-command (executable-find "ros2")
(defcustom +ros-ros2-command "ros2"
"ROS 2 \"ros2\" command."
:group 'minemacs-robot)
:group 'minemacs-robot
:type '(choice file string))

(dolist (ext-mode '(("\\.rviz\\'" . conf-unix-mode)
("\\.urdf\\'" . xml-mode)
Expand All @@ -33,7 +36,8 @@
("\\.action\\'" . gdb-script-mode)))
(add-to-list 'auto-mode-alist ext-mode))

(+deferred-when! (or +ros-mcap-command +ros-rosbag-command +ros-ros2-command)
(+deferred-when! (cl-some (lambda (cmd) (and cmd (executable-find cmd)))
(list +ros-mcap-command +ros-rosbag-command +ros-ros2-command))
;; A mode to display info from ROS bag files (via MCAP)
(define-derived-mode rosbag-info-mode conf-colon-mode "ROS bag"
"Major mode for viewing ROS/ROS2 bag files."
Expand Down
2 changes: 1 addition & 1 deletion modules/me-rss.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(defcustom +elfeed-images-dir "~/Pictures/elfeed/"
"Directory of downloaded pictures."
:group 'minemacs-elfeed)
(defcustom +yt-dlp-command (executable-find "yt-dlp")
(defcustom +yt-dlp-command "yt-dlp"
"The \"yt-dlp\" command."
:group 'minemacs-tools)
:custom
Expand Down

0 comments on commit a976cab

Please sign in to comment.