Package: emacs;
Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>
Date: Fri, 4 Apr 2014 15:05:01 UTC
Severity: normal
Found in version 24.3.50
Done: joaotavora <at> gmail.com (João Távora)
Bug is archived. No further changes may be made.
View this message in rfc822 format
From: joaotavora <at> gmail.com (João Távora) To: Stefan Monnier <monnier <at> iro.umontreal.ca> Cc: 17183 <at> debbugs.gnu.org Subject: bug#17183: can't insert a quote pair before another Date: Sun, 06 Apr 2014 02:26:15 +0100
Stefan Monnier <monnier <at> iro.umontreal.ca> writes: > Package: Emacs > Version: 24.3.50 > but instead I had to use C-q " twice, which was rather unpleasant. Yes seen it. Rather unpleasant indeed. How does this look? === modified file 'lisp/ChangeLog' *** lisp/ChangeLog 2014-04-04 23:31:02 +0000 --- lisp/ChangeLog 2014-04-06 01:23:51 +0000 *************** *** 1,3 **** --- 1,11 ---- + 2014-04-06 João Távora <joaotavora <at> gmail.com> + + * elec-pair.el (electric-pair--skip-whitespace): With quote + syntax, ensure not outside string before insertion started. . + (electric-pair-post-self-insert-function): Pass char and syntax to + electric-pair--skip-whitespace. Save point instead of + `save-excursion'. (Bug#17183) + 2014-04-04 João Távora <joaotavora <at> gmail.com> * elec-pair.el: === modified file 'lisp/elec-pair.el' *** lisp/elec-pair.el 2014-04-04 23:31:02 +0000 --- lisp/elec-pair.el 2014-04-06 01:19:47 +0000 *************** *** 151,163 **** (const :tag "Newline" ?\n)) (list character))) ! (defun electric-pair--skip-whitespace () "Skip whitespace forward, not crossing comment or string boundaries." ! (let ((saved (point)) ! (string-or-comment (nth 8 (syntax-ppss)))) ! (skip-chars-forward (apply #'string electric-pair-skip-whitespace-chars)) ! (unless (eq string-or-comment (nth 8 (syntax-ppss))) ! (goto-char saved)))) (defvar electric-pair-text-syntax-table prog-mode-syntax-table "Syntax table used when pairing inside comments and strings. --- 151,171 ---- (const :tag "Newline" ?\n)) (list character))) ! (defun electric-pair--skip-whitespace (char syntax) "Skip whitespace forward, not crossing comment or string boundaries." ! (let* ((saved (point)) ! (ppss (syntax-ppss)) ! (string-or-comment (nth 8 ppss))) ! (unless (and ! (eq syntax ?\") ! (unwind-protect ! (progn ! (delete-char -1) ! (not (nth 3 (syntax-ppss)))) ! (insert-char char))) ! (skip-chars-forward (apply #'string electric-pair-skip-whitespace-chars)) ! (unless (eq string-or-comment (nth 8 (syntax-ppss))) ! (goto-char saved))))) (defvar electric-pair-text-syntax-table prog-mode-syntax-table "Syntax table used when pairing inside comments and strings. *************** *** 502,521 **** (if (functionp electric-pair-skip-self) (funcall electric-pair-skip-self last-command-event) electric-pair-skip-self)) ! (save-excursion (when (setq skip-whitespace-info (if (functionp electric-pair-skip-whitespace) (funcall electric-pair-skip-whitespace) electric-pair-skip-whitespace)) ! (electric-pair--skip-whitespace)) ! (eq (char-after) last-command-event)))) ;; This is too late: rather than insert&delete we'd want to only ;; skip (or insert in overwrite mode). The difference is in what ;; goes in the undo-log and in the intermediate state which might ;; be visible to other post-self-insert-hook. We'll just have to ;; live with it for now. (when skip-whitespace-info ! (electric-pair--skip-whitespace)) (delete-region (1- pos) (if (eq skip-whitespace-info 'chomp) (point) pos)) --- 510,531 ---- (if (functionp electric-pair-skip-self) (funcall electric-pair-skip-self last-command-event) electric-pair-skip-self)) ! (let ((saved (point))) (when (setq skip-whitespace-info (if (functionp electric-pair-skip-whitespace) (funcall electric-pair-skip-whitespace) electric-pair-skip-whitespace)) ! (electric-pair--skip-whitespace last-command-event syntax)) ! (prog1 ! (eq (char-after) last-command-event) ! (goto-char saved))))) ;; This is too late: rather than insert&delete we'd want to only ;; skip (or insert in overwrite mode). The difference is in what ;; goes in the undo-log and in the intermediate state which might ;; be visible to other post-self-insert-hook. We'll just have to ;; live with it for now. (when skip-whitespace-info ! (electric-pair--skip-whitespace last-command-event syntax)) (delete-region (1- pos) (if (eq skip-whitespace-info 'chomp) (point) pos))
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.