diff options
| author | Philip Kaludercic | 2022-07-31 12:45:29 +0200 |
|---|---|---|
| committer | Philip Kaludercic | 2022-07-31 12:47:11 +0200 |
| commit | df8dede8585257a2ee76ed93d6ecb6cf117e124a (patch) | |
| tree | bc335589d4060a90edd2d1e3083b14172083d82b | |
| parent | ca2d3ed74c63167c7d8378482016efea9756dd17 (diff) | |
| download | emacs-df8dede8585257a2ee76ed93d6ecb6cf117e124a.tar.gz emacs-df8dede8585257a2ee76ed93d6ecb6cf117e124a.zip | |
Fix electric paring in rcirc buffers
* rcirc.el (rcirc--electric-pair-inhibit): Add new predicate function.
(rcirc-mode): Use rcirc--electric-pair-inhibit.
| -rw-r--r-- | lisp/net/rcirc.el | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 54d7861f445..065398b64af 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -1388,6 +1388,21 @@ Each element looks like (FILENAME . TEXT).") | |||
| 1388 | "The current number of responses printed in this channel. | 1388 | "The current number of responses printed in this channel. |
| 1389 | This number is independent of the number of lines in the buffer.") | 1389 | This number is independent of the number of lines in the buffer.") |
| 1390 | 1390 | ||
| 1391 | (defun rcirc--electric-pair-inhibit (char) | ||
| 1392 | "Check whether CHAR should be paired by `electric-pair-mode'. | ||
| 1393 | This uses the default value inhibition predicate (as set by | ||
| 1394 | `electric-pair-inhibit-predicate'), but ignores all text prior to | ||
| 1395 | the prompt so that mismatches parentheses by some other message | ||
| 1396 | does not confuse the pairing." | ||
| 1397 | (let ((fallback (default-value 'electric-pair-inhibit-predicate))) | ||
| 1398 | ;; The assumption is that this function is only bound by | ||
| 1399 | ;; `rcirc-mode', and should never be the global default. | ||
| 1400 | (cl-assert (not (eq fallback #'rcirc--electric-pair-inhibit))) | ||
| 1401 | (save-restriction | ||
| 1402 | (widen) | ||
| 1403 | (narrow-to-region rcirc-prompt-start-marker (point-max)) | ||
| 1404 | (funcall fallback char)))) | ||
| 1405 | |||
| 1391 | (defun rcirc-mode (process target) | 1406 | (defun rcirc-mode (process target) |
| 1392 | "Initialize an IRC buffer for writing with TARGET. | 1407 | "Initialize an IRC buffer for writing with TARGET. |
| 1393 | PROCESS is the process object used for communication. | 1408 | PROCESS is the process object used for communication. |
| @@ -1459,6 +1474,9 @@ PROCESS is the process object used for communication. | |||
| 1459 | (when rcirc-cycle-completion-flag | 1474 | (when rcirc-cycle-completion-flag |
| 1460 | (setq-local completion-cycle-threshold t)) | 1475 | (setq-local completion-cycle-threshold t)) |
| 1461 | 1476 | ||
| 1477 | (setq-local electric-pair-inhibit-predicate | ||
| 1478 | #'rcirc--electric-pair-inhibit) | ||
| 1479 | |||
| 1462 | (run-mode-hooks 'rcirc-mode-hook)) | 1480 | (run-mode-hooks 'rcirc-mode-hook)) |
| 1463 | 1481 | ||
| 1464 | (defun rcirc-update-prompt (&optional all) | 1482 | (defun rcirc-update-prompt (&optional all) |