当前位置:网站首页>如何使用 align-regexp 对齐 userscript 元信息
如何使用 align-regexp 对齐 userscript 元信息
2022-07-26 16:41:00 【飞驰的西瓜】
有一个 userscript,元信息[1]没有严格对齐,可以工作,但是不美观,怎么办呢?
// ==UserScript==
// @name Github Commented Issues
// @namespace https://github.com/jiacai2050
// @description Show your commented issues on github easily.
// @match https://github.com/issues*
// @author jiacai2050
// @version 0.2.3
// @icon https://github.githubassets.com/favicons/favicon.svg
// @grant none
// ==/UserScript==align-regexp to the resuce!
C-u M-x align-regexp @[a-z]+\(\s-*\) RET 1 RET 1 RET n
解释上面的命令前,先看下其签名:
(align-regexp BEG END REGEXP &optional GROUP SPACING REPEAT)•REGEXP 用以对齐的正则,至少包含一个 group 即 () ,通过修改这个 group 来达到对齐的效果
• @[a-z]+\(\s-*\) 这个正则表示用 @name 后的零或多个空格作为修改的 group
• \s- 表示空格,具体语法可参考 Regexp-Backslash[2]
• GROUP 标明正则式中哪个 group 用做修改来达到对齐效果
• SPACING 不同列之间的空格数
• REPEAT 是否作用在这一整行上,在本示例无所谓,因为最终只有两列
// ==UserScript==
// @name Github Commented Issues
// @namespace https://github.com/jiacai2050
// @description Show your commented issues on github easily.
// @match https://github.com/issues*
// @author jiacai2050
// @version 0.2.3
// @icon https://github.githubassets.com/favicons/favicon.svg
// @grant none
// ==/UserScript==最后,封装成一个函数
(defun my/align-userscript-metablock (start end)
(interactive "r")
(align-regexp start end
"@[a-z]+\\(\\s-*\\)" 1 1 t))练习
the quick brown fox
jumped over the lazy
dogs the quick brownC-u M-x align-regexp \(\s-*\)\s- RET 1 RET 0 RET y
the quick brown fox
jumped over the lazy
dogs the quick brown参考
• Aligning text[3]
• Aligning columns in Emacs[4]
• Emacs: Align Text[5]
引用链接
[1] 元信息: https://violentmonkey.github.io/api/metadata-block/[2] Regexp-Backslash: https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Backslash.html[3] Aligning text: http://pragmaticemacs.com/emacs/aligning-text/[4] Aligning columns in Emacs: https://blog.lambda.cx/posts/emacs-align-columns/[5] Emacs: Align Text: http://ergoemacs.org/emacs/emacs_align_and_sort.html
边栏推荐
- Tensorflow Lite source code analysis
- Three misunderstandings of CRM implementation: lack of strategy, lack of identity, and technology first
- About the difference between BigDecimal conversion string toengineeringstring, toplainstring and toString
- Matlab论文插图绘制模板第40期—带偏移扇区的饼图
- [Development Tutorial 9] crazy shell arm function mobile phone-i2c tutorial
- Heavy! Zeng Xuezhong was promoted to vice chairman and CEO of zhanrui, and Chu Qingren was appointed as co CEO!
- [Luogu p8063] shortest paths (graph theory)
- Review the past and know the new MySQL isolation level
- Win11 auto delete file setting method
- 浅谈云原生边缘计算框架演进
猜你喜欢

Crazy God redis notes 02

40个高质量信息管理专业毕设项目分享【源码+论文】(六)

Can TCP and UDP use the same port?

Recurrence of historical loopholes in ThinkPHP

Review the past and know the new MySQL isolation level

Win11 how to close a shared folder

Anaconda download and Spyder error reporting solution

【飞控开发基础教程3】疯壳·开源编队无人机-串口(基础收发)

What is a distributed timed task framework?

TCP 和 UDP 可以使用相同端口吗?
随机推荐
Is it safe for Guosen Securities to open an account? How can I find the account manager
Redis hotspot key and big value
After Oracle creates a table partition, the partition is not given during the query, but the value specified for the partition field will be automatically queried according to the partition?
Win11系统如何一键进行重装?
[Luogu cf643f] bears and juice (conclusion)
[classification] vgg16 training record
Linear regression from zero sum using mxnet
Pack tricks
MySQL foundation - basic database operation
Alibaba cloud Toolkit - project one click deployment tool
Mount NFS storage
[ctfshow-web]反序列化
[Luogu p8063] shortest paths (graph theory)
What kind of product is the Jetson nano? (how about the performance of Jetson nano)
37. [categories of overloaded operators]
Current limiting comparison: how to choose sentinel vs hystrix?
PyQt5快速开发与实战 3.4 信号与槽关联
“青出于蓝胜于蓝”,为何藏宝计划(TPC)是持币生息最后的一朵白莲花
Quickly learn to configure local and network sources of yum, and learn to use yum
[Development Tutorial 9] crazy shell arm function mobile phone-i2c tutorial