我使用-0.13.1的包后缀自定义常春藤的load-path:
(add-to-list 'load-path "~/.zeroemacs/elpa/ivy-0.13.1/")但是,当常春藤软件包升级到0.14.1时,我不得不手动修改load-path
(add-to-list 'load-path "~/.zeroemacs/elpa/ivy-0.14.1/")是否有可能用与任何序列号相匹配的ivy-*之类的东西来替换它?
发布于 2021-03-02 13:11:41
版本号有许多形状和大小。下面的latest-file-version函数不是试图处理任何和所有版本格式,而是依赖于比较version-to-list函数接受的版本字符串。version-to-list的文档包括对它接受的内容的描述:
版本语法由以下EBNF提供:
版本::=编号(分隔符号)*。
号码:::= (0=1,1,2,2,+)+。
分隔符::=‘version-分离器’(见)
“版本-正则主义者”(见)。
如果分隔符与“version-regexp”中的元素匹配,则数字部分是可选的。
可以在latest-file-version设置中使用load-path函数,如下所示:
(add-to-list 'load-path (latest-file-version "~/.zeroemacs/elpa" "ivy"))第一个参数是要检查的目录,第二个参数是要检查的版本文件名或目录名的前缀。
(defun latest-file-version (dir prefix)
"Get the latest version of files in DIR starting with PREFIX.
Only filenames in DIR with the form PREFIX-version are
considered, where the version portion of the filename must have
valid version syntax as specified for `version-to-list'. Raise an
error if no filenames in DIR start with PREFIX or if no valid
matching versioned filenames are found."
(let* ((vsn-regex (concat "^" prefix "-\\(.+\\)$"))
(vsn-entries
(seq-reduce
#'(lambda (acc s)
(if (string-match vsn-regex s)
(let* ((m (match-string 1 s))
(vsn (condition-case nil
(version-to-list m)
(error nil))))
(if vsn
(cons (cons m s) acc)
acc))
acc))
(directory-files dir nil nil t) nil)))
(if vsn-entries
(concat (file-name-as-directory dir)
(cdar (sort vsn-entries
#'(lambda (v1 v2)
(version<= (car v2) (car v1))))))
(error "No valid versioned filenames found in %s with prefix \"%s-\""
dir prefix))))用emacs 27.1测试。
https://stackoverflow.com/questions/66405741
复制相似问题