From 89abf5a1c4e3ed66601e9863a340c019f7ffd44e Mon Sep 17 00:00:00 2001 From: Aoran Zeng Date: Sun, 10 Sep 2023 17:18:05 +0800 Subject: [PATCH] Add basic support for `Emacs` --- chsrc.c | 25 +++++++++++++++++++++++-- chsrc.h | 17 +++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/chsrc.c b/chsrc.c index 8dde121..4319993 100644 --- a/chsrc.c +++ b/chsrc.c @@ -1512,6 +1512,27 @@ wr_tex_setsrc(char* option) } + + +void +wr_emacs_setsrc(char* option) +{ + int index = 0; + if (NULL!=option) { + index = lets_find_mirror(wr_emacs, option); + } else { + index = lets_test_speed(wr_emacs); + } + + source_info source = wr_emacs_sources[index]; + chsrc_say_selection (&source); + + xy_warn("chsrc: 抱歉,Emacs换源涉及Elisp,您可手动查阅并换源:"); + puts(source.url); + + chsrc_say_thanks (&source); +} + /************************************** Begin Target Matrix ****************************************/ def_target_info(pl_ruby); def_target_info(pl_python); @@ -1594,12 +1615,12 @@ def_target_info(wr_tex); target_info wr_anaconda_target = {NULL, NULL, NULL, 0}, - wr_emacs_target = {NULL, NULL, NULL, 0}, + wr_emacs_target = {wr_emacs_setsrc, NULL, wr_emacs_sources, wr_emacs_sources_n}, wr_brew_target = {NULL, NULL, NULL, 0}; static const char *wr_anaconda[] = {"conda", "anaconda", NULL, targetinfo(&wr_anaconda_target)}, -*wr_emacs [] = {"emacs", NULL, targetinfo(&wr_emacs_target)}, +*wr_emacs [] = {"emacs", "elpa", NULL, targetinfo(&wr_emacs_target)}, *wr_tex [] = {"latex", "ctan", "tex", "texlive", "miktex", "tlmgr", "mpm", NULL, targetinfo(&wr_tex_target)}, *wr_brew [] = {"brew", "homebrew", NULL, targetinfo(&wr_brew_target)}, **wr_softwares[] = diff --git a/chsrc.h b/chsrc.h index 8e181d9..746d422 100644 --- a/chsrc.h +++ b/chsrc.h @@ -500,9 +500,22 @@ wr_tex_sources[] = { {&Lzuoss, "https://mirror.lzu.edu.cn/CTAN/systems/texlive/tlnet"}, {&Jlu, "https://mirrors.jlu.edu.cn/CTAN/systems/texlive/tlnet"}, {&Sustech, "https://mirrors.sustech.edu.cn/CTAN/systems/texlive/tlnet"} -}; +}, +/** + * 2023-09-10 更新 + * + * @note Emacs用户往往只需要一次性换源,只会极少次调用 chsrc,我们只给用户提供文档 + */ +wr_emacs_sources[] = { + {&Sjtug_Zhiyuan, "https://mirrors.sjtug.sjtu.edu.cn/docs/emacs-elpa"}, + {&Tuna, "https://mirrors.tuna.tsinghua.edu.cn/help/elpa/"}, + {&Bfsu, "https://mirrors.bfsu.edu.cn/help/elpa/"}, + {&Ustc, "https://mirrors.ustc.edu.cn/help/elpa.html"}, + {&Zju, "https://mirrors.zju.edu.cn/docs/elpa/"} +}; + /* 辅助函数 */ @@ -565,7 +578,7 @@ def_target_sources_n(os_kali); def_target_sources_n(os_openbsd); def_ def_target_sources_n(os_arch); def_target_sources_n(os_gentoo); def_target_sources_n(os_netbsd); def_target_sources_n(os_deepin); def_target_sources_n(os_openeuler); def_target_sources_n(os_openkylin); -def_target_sources_n(wr_tex); +def_target_sources_n(wr_tex); def_target_sources_n(wr_emacs); /* Target Info */ typedef struct {