emacs php,如何在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
"\n\t%s\n\t%s\n\t%s\n"
"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.
如果禁止php-check-html-for-indentation不是正確的事情,因為它除了警告之外還有其他的東西,那么你最好的方法是建議php-check-html-for-indentation,基本上重新定義它,但沒有打電話給lwarn.要做到這一點,你的php-check-html-for-indentation的defadvice將重用原始定義,但沒有調用lwarn而沒有任何ad-do-it.請參閱Elisp手冊,節點建議功能和建議.
標簽:php,emacs,elisp,html,emacs23
來源: https://codeday.me/bug/20190629/1324357.html
總結
以上是生活随笔為你收集整理的emacs php,如何在Emacs中关闭php-indent警告的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php5.5 sqlserver 201
- 下一篇: java生成三级级联的数据,微信小程序三