この答えは、上記の私のコメントに基づいています。
defadvice
別の解決策よりも適切ではありません。それは他の解決策よりも決して適切ではありません。
defadvice
他の方法で問題を解決できない場合の最後の手段です。
限目。
使用するときはいつでもdefadvice
、パッケージ開発者が依存するEmacsAPIを基本的に変更していることに注意してください。
これらの動作を微妙に変更すると、Emacs APIがで壊れているため、「バグ」を報告すると、最終的にはパッケージ開発者に多くの問題が発生しますdefadvice
。
したがって、機能をローカルで変更する場合は、既存の機能を使用して新しいコマンドを定義し、それに再マップする方法があります。
ウィットするには(あなたが参照した答えから):
(defun comment-or-uncomment-region-or-line ()
"Comments or uncomments the region or the current line if there's no active region."
(interactive)
(let (beg end)
(if (region-active-p)
(setq beg (region-beginning) end (region-end))
(setq beg (line-beginning-position) end (line-end-position)))
(comment-or-uncomment-region beg end)
(next-line)))
(global-set-key [remap comment-dwim] 'comment-or-uncomment-region-or-line)