广告激活是做什么的? [英] What does ad-activate do?

查看:435
本文介绍了广告激活是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

答案中,我注意到:

;; Align with spaces only
(defadvice align-regexp (around align-regexp-with-spaces)
  "Never use tabs for alignment."
  (let ((indent-tabs-mode nil))
    ad-do-it))
(ad-activate 'align-regexp)

这个听起来很有希望,但是。 ..它是做什么的?

This sounds promising, but... what does it do?!

我在代码块上尝试了 eval-region 但是对于我来说,它所做的只是将以下内容添加到 align-regexp 文档中:

I tried eval-region on the block of code. But for me, all it does is adding the following to the align-regexp docs:


建议使用此功能。

周围建议align-regexp-with-spaces:

不要使用选项卡进行对齐。

Around-advice `align-regexp-with-spaces':
Never use tabs for alignment.

我似乎无法实际使用 align-regexp-有空格,如果这是应该是什么效果...什么我缺少?

I don't seem to be able to actually use align-regexp-with-spaces, if that's what should be the effect... What am I missing?

我使用GNU Emacs版本24.0.96.1( i386-mingw-nt6.1.7601)。

I used GNU Emacs version 24.0.96.1 (i386-mingw-nt6.1.7601).

推荐答案

在提出这个问题的同时,我意识到我没有得到想法建议功能

While asking this question, I realized that I just didn't get the idea of advising functions.

我明白了:


  • align-regexp-with -spaces 不是一个函数,也不是一个变量,而只是一个名字(启用/禁用单个建议)

  • (ad-activate'align-regexp) align-regexp 只是我建议这样做:不要使用选项卡

  • align-regexp-with-spaces isn't a function nor a variable but only a name (to enable/disable single pieces of advice)
  • ever since (ad-activate 'align-regexp), align-regexp just does what I 'advised' it to: not to use tabs

所以: ad-activate 激活建议,有效地改变原来的功能的行为。非常好!

So: ad-activate activates the advice, effectively changing the original function's behavior. Great!

我不知道为什么这比'code> align-regexp 。但是再一次我不太了解Emacs Lisp。

I don't get why this is 'better' than defining a function around align-regexp though. But then again I don't know much about Emacs Lisp.

我怕这些额外的文档只会添加到混乱中...

I'm afraid the extra lines of documentation only added to the confusion...

这篇关于广告激活是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆