Hi Uwe, Here are the original patches (matlab-elecp-patch and matlab-elecp-patch_PHM) that would be applied to commit [5069e3c], and the patch corresponding to the PR in question (0001-fix-electric-pair-handling-of-single-quote.patch) to be applied to be applied to [b700722]. Content-wise, the PR is the same as the two original patches applied serially.
Here is the text of the original issue: note: I formatted this email in markdown for readability (let me know if > there's a better way). > > I use **electric-pair-mode**. If you don't you can turn it on locally with > ``` > (electric-pair-local-mode t) > ``` > to see what the issue is. > > Briefly, with **electric-pair-mode** on (locally or globally), If I type > the characters `(abc)def`, I get the same output. The characters that pair > are the ones in the syntax table (use `describe-syntax' to see it) that are > of type "open", "close", or "string". > > In **matlab-mode**, the pairs (), [], {} (all "open"/"close" type) work > fine, as does the "string" type delimiter " (aka, double-quote, #x22, ?") > because it is listed in the variable `electric-pair-pairs`. The only one > that does NOT work is the "string" type delimiter ' (aka, single-quote, > #x27, ?'). So with the `(abc)def` example above, with #x27, I get: > ``` > 'abc'def' > ``` > Note the single-quote at the end of the output string after the `f`. > Peter
From d0f287a3775af9eb70bd0917c85af49774215a8d Mon Sep 17 00:00:00 2001 From: Peter Mao <peter....@gmail.com> Date: Fri, 21 Apr 2023 22:45:12 -0700 Subject: [PATCH] fix electric-pair handling of single-quote combines patches from Eric Ludlam and Peter Mao from 2022. In matlab-mode with electric-pair turned on, the closing quote was not being handled properly leaving too many single-quotes after a string. --- matlab.el | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/matlab.el b/matlab.el index 88c72e0..d03b7b8 100644 --- a/matlab.el +++ b/matlab.el @@ -11,7 +11,7 @@ (defconst matlab-mode-version "Current version of MATLAB(R) mode.") ;; -;; Copyright (C) 1997-2021 Eric M. Ludlam +;; Copyright (C) 1997-2022 Eric M. Ludlam ;; Copyright (C) 1991-1997 Matthew R. Wette ;; ;; This program is free software; you can redistribute it and/or modify @@ -1386,6 +1386,14 @@ (define-derived-mode matlab-mode (make-local-variable 'show-paren-data-function) (setq show-paren-data-function 'matlab-show-paren-or-block) + ;; Electric pair mode needs customization around transpose + (make-local-variable 'electric-pair-inhibit-predicate) + (setq electric-pair-inhibit-predicate 'matlab-electric-pair-inhibit-predicate) + + ;; Electric pair mode - handle ' as string delimiter correctly + (make-local-variable 'electric-pair-pairs) + (setq electric-pair-pairs '((39 . 39))) + ;; If first function is terminated with an end statement, then functions have ;; ends. (if (matlab-do-functions-have-end-p) @@ -2925,6 +2933,19 @@ (defun matlab-show-paren-or-block (list here-beg here-end there-beg there-end mismatch) )))))) +;;; Electric pair mode ============================================ + +(defun matlab-electric-pair-inhibit-predicate (char) + "Return non-nil if `electric-pair-mode' should not pair this char." + (or (funcall 'electric-pair-default-inhibit char) + (cond + ((and (eq char ?') + (progn (forward-char -1) + (looking-at "\\w\\|\\s_\\|\\."))) + t) + )) + ) + ;;; M Code verification ============================================ (defun matlab-toggle-show-mlint-warnings () -- 2.34.1
matlab-elecp-patch
Description: Binary data
matlab-elecp-patch_PHM
Description: Binary data
_______________________________________________ Matlab-emacs-discuss mailing list Matlab-emacs-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matlab-emacs-discuss