[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/xeft e694278a16 53/55: Improve auto-compile/download co
From: |
ELPA Syncer |
Subject: |
[elpa] externals/xeft e694278a16 53/55: Improve auto-compile/download commands |
Date: |
Fri, 13 Jan 2023 23:58:40 -0500 (EST) |
branch: externals/xeft
commit e694278a16b3bbecaca2fe5ef98c86f187948447
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
Improve auto-compile/download commands
* xeft.el (xeft--require-xapian-lite): Refactor out this function.
(xeft--download-module): Use read-multiple-choice.
(xeft): Factor out xeft--require-xapian-lite.
---
xeft.el | 76 +++++++++++++++++++++++++++++++++++------------------------------
1 file changed, 41 insertions(+), 35 deletions(-)
diff --git a/xeft.el b/xeft.el
index 4f3d6df801..77d1a7defa 100644
--- a/xeft.el
+++ b/xeft.el
@@ -178,22 +178,47 @@ This function takes no arguments and return a list of
absolute paths."
(defvar xeft--mac-module-url
"https://git.sr.ht/~casouri/xapian-lite/refs/download/v2.0.0/xapian-lite-amd64-macos.dylib"
"URL for pre-built dynamic module for Mac.")
+(defun xeft--require-xapian-lite ()
+ "Require ‘xapian-lite’, if non-exist, try to build or download it.
+If success return non-nil, otherwise return nil."
+ (if (require 'xapian-lite nil t)
+ t
+ ;; I can hide download option for non-Linux/mac users, but I’m
+ ;; lazy.
+ (let* ((choice (car (read-multiple-choice
+ "Xeft needs the dynamic module to work, how do you
want to get it? "
+ '((?c "compile locally" "Compile the dynamic module
locally, this requires libxapian, C++ compiler, and Make")
+ (?d "download from Internet" "Download pre-built
dynamic module from Internet")
+ (?q "quit")))))
+ (success (pcase choice
+ (?d (xeft--download-module))
+ (?c (xeft--compile-module))
+ (_ nil))))
+ (if success
+ (progn (require 'xapian-lite) t)
+ nil))))
+
(defun xeft--download-module ()
"Download pre-built module from GitHub. Return non-nil if success."
- (require 'url)
- (let ((module-path (expand-file-name
- "xapian-lite.so"
- (file-name-directory
- (locate-library "xeft.el" t)))))
- (cond
- ((eq system-type 'gnu/linux)
- (url-copy-file xeft--linux-module-url module-path)
- t)
- ((eq system-type 'darwin)
- (url-copy-file xeft--mac-module-url module-path)
- t)
- (t (message "No pre-built module for this operating system. We only have
them for GNU/Linux and macOS")
- nil))))
+ (when (y-or-n-p "You are about to download binary from Internet without
checking checksum, do you want to continue?")
+ (let ((system (car (read-multiple-choice
+ "Which prebuilt binary do you want to download? "
+ '((?1 "amd64-GNU/Linux"
+ "GNU/Linux on Intel/AMD x86_64 CPU")
+ (?2 "amd64-macOS"
+ "macOS on Intel/AMD x86_64 CPU")
+ (?q "quit")))))
+ (module-path (expand-file-name
+ "xapian-lite.so"
+ (file-name-directory
+ (locate-library "xeft.el" t)))))
+ (if (eq system ?q)
+ nil
+ (url-copy-file
+ (pcase system
+ (1 xeft--linux-module-url)
+ (2 xeft--mac-module-url))
+ module-path)))))
;;; Helpers
@@ -273,27 +298,8 @@ This function takes no arguments and return a list of
absolute paths."
(user-error "XEFT-DATABASE must be an absolute path"))
(when (not (file-exists-p xeft-database))
(mkdir xeft-database t))
- (unless (require 'xapian-lite nil t)
- ;; I can hide download option for non-Linux/mac users, but I’m
- ;; lazy.
- (let* ((choice (read-char (concat
- "Xeft needs the dynamic module to work, "
- "download pre-built module "
- (propertize "[b]" 'face 'bold)
- ", compile locally "
- (propertize "[c]" 'face 'bold)
- ", or give up "
- (propertize "[q]" 'face 'bold)
- "?")))
- (success (cond ((eq choice ?b)
- (xeft--download-module))
- ((eq choice ?c)
- (xeft--compile-module))
- (t nil))))
- (when success
- (require 'xapian-lite))))
- (if (not (featurep 'xapian-lite))
- (message "Since there is no require dynamic module, we can’t start Xeft")
+ (if (not (xeft--require-xapian-lite))
+ (message "Cannot start xeft because required dynamic module is missing")
(setq xeft--last-window-config (current-window-configuration))
(switch-to-buffer (xeft--buffer))
(when (not (derived-mode-p 'xeft-mode))
- [elpa] externals/xeft a3050c1596 20/55: * xeft.el (xeft-ignore-extension): Explain the option more clearly., (continued)
- [elpa] externals/xeft a3050c1596 20/55: * xeft.el (xeft-ignore-extension): Explain the option more clearly., ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 035ae7f3d0 22/55: * xeft.el: Update commentary about 'xeft-recursive'., ELPA Syncer, 2023/01/13
- [elpa] externals/xeft ad2d7b259d 23/55: Don't highlight short keywords., ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 7646d9d254 24/55: * xeft-module.cc (copy_string): Remember to free string buffer., ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 71febb833f 26/55: Improve latency, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 1c1b449d21 25/55: Add semicolon after macro, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 8b8c4bd37a 27/55: Improve README, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 2b515faf2e 29/55: * xeft-module.cc (copy_string): Fix free statement;, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft b980aac44f 45/55: Pull xapian-lite from GitHub, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft ea43335993 35/55: Extend handled query syntax and document it, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft e694278a16 53/55: Improve auto-compile/download commands,
ELPA Syncer <=
- [elpa] externals/xeft cb4b595b6a 50/55: Update gitignore, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 3a60ed7639 36/55: Provide option to download dynamic module automatically, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 39430a861a 47/55: Update to v3.0, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft dd14e69939 33/55: * README.md: Remove text about the dynamic mocule., ELPA Syncer, 2023/01/13
- [elpa] externals/xeft f05eca90f6 46/55: * Makefile (CXXFLAGS): Remove -stdlib=libc++, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 270eeb1084 44/55: * xeft.el: Add version for package-vc-install., ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 0f56356d24 48/55: Switch to sr.ht, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft fa63432715 11/55: * Makefile (xeft-module.so): Fix linking flags, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 26389942e9 37/55: Minor change, ELPA Syncer, 2023/01/13
- [elpa] externals/xeft 6efff4f20d 12/55: Add conexcept qualifier, ELPA Syncer, 2023/01/13