如何在Emacs中关闭php-indent警告
在Emacs中使用
PHP代码和HTML标记编辑
PHP文件时,我会继续收到警告:
Warning (php-indent): Indentation fails badly with mixed HTML and PHP. Look for an Emacs Lisp library that supports "multiple major modes" like mumamo,mmm-mode or multi-mode. 它出现在我wiindow的底部,占据了我编辑屏幕的一半.我怎么关掉这个? 我知道你可以添加各种“附加组件”和模式,以使Emacs格式化PHP HTML,但我只想关闭警告.我怎么能这样做? 编辑: 这是php-mode.el文件的一部分,其中上述错误似乎来自: (defvar php-completion-table nil "Obarray of tag names defined in current tags table and functions know to PHP.") (defvar php-warned-bad-indent nil) (make-variable-buffer-local 'php-warned-bad-indent) ;; Do it but tell it is not good if html tags in buffer. (defun php-check-html-for-indentation () (let ((html-tag-re "</?sw+.*?>") (here (point))) (if (not (or (re-search-forward html-tag-re (line-end-position) t) (re-search-backward html-tag-re (line-beginning-position) t))) t (goto-char here) (setq php-warned-bad-indent t) (lwarn 'php-indent :warning "nt%snt%snt%sn" "Indentation fails badly with mixed HTML and PHP." "Look for an Emacs Lisp library that supports "multiple" "major modes" like mumamo,mmm-mode or multi-mode.") nil))) (defun php-cautious-indent-region (start end &optional quiet) (if (or php-warned-bad-indent (php-check-html-for-indentation)) (funcall 'c-indent-region start end quiet))) (defun php-cautious-indent-line () (if (or php-warned-bad-indent (php-check-html-for-indentation)) (funcall 'c-indent-line))) 解决方法
轻击Emacs源代码,我在任何地方都找不到该消息.它可能来自您从init文件加载的其他一些代码.
检查您加载的库 – grep它们以获取消息.这将让您了解如何禁止消息.这取决于它是如何创建的等. 例如,您可以建议(defadvice)发出消息的函数,但是您可能必须使用建议来替换不发出消息的类似代码来替换函数的代码. 但首先找到罪魁祸首代码.可能有一种简单的方法来禁止消息,例如用户选项. 更新— 好的,发出警告的功能是lwarn.立即,您可以(至少作为解决方法)自定义选项警告 – 最小级别和可能警告 – 最小 – 日志级别,以禁止警告.但这也会抑制同级别的其他警告. 调用lwarn的函数是php-check-html-for-indentation,它无条件地调用它. 如果禁止php-check-html-for-indentation不是正确的事情,因为它除了警告之外还有其他的东西,那么你最好的方法是建议php-check-html-for-indentation,基本上重新定义它,但没有打电话给lwarn.要做到这一点,你的php-check-html-for-indentation的defadvice将重用原始定义,但没有调用lwarn而没有任何ad-do-it.请参阅Elisp手册,节点建议功能和建议. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |