(let ((start
(if (and comment-start comment-use-syntax)
(when (or electric-quote-comment electric-quote-string)
- (let ((syntax (syntax-ppss)))
- (and (or (and electric-quote-comment (nth 4 syntax))
+ (let* ((syntax (syntax-ppss))
+ (beg (nth 8 syntax)))
+ (and beg
+ (or (and electric-quote-comment (nth 4 syntax))
(and electric-quote-string (nth 3 syntax)))
- (nth 8 syntax))))
+ ;; Do not requote a quote that starts or ends
+ ;; a comment or string.
+ (eq beg (nth 8 (save-excursion
+ (syntax-ppss (1- (point)))))))))
(and electric-quote-paragraph
(derived-mode-p 'text-mode)
(or (eq last-command-event ?\`)
(match-string 1)
(buffer-substring-no-properties (point) (line-end-position)))
hits)))
- (xref--convert-hits hits regexp)))
+ (xref--convert-hits (nreverse hits) regexp)))
(defun xref--rgrep-command (regexp files dir ignores)
(require 'find-dired) ; for `find-name-arg'
(skip-chars-backward "\"")
(mark-sexp -1)))
+\f
+;;; Electric quotes
+(define-electric-pair-test electric-quote-string
+ "" "'" :expected-string "'" :expected-point 2
+ :fixture-fn #'electric-quote-local-mode
+ :bindings '((electric-quote-string . t))
+ :test-in-comments nil :test-in-strings nil)
+
(provide 'electric-tests)
;;; electric-tests.el ends here