Function: skeleton-pair-insert-maybe

skeleton-pair-insert-maybe is an autoloaded, interactive and byte-compiled function defined in skeleton.el.gz.

Signature

(skeleton-pair-insert-maybe ARG)

Documentation

Insert the character you type ARG times.

With no ARG, if skeleton-pair is non-nil, pairing can occur. If the region is visible the pair is wrapped around it depending on skeleton-autowrap. Else, if skeleton-pair-on-word is non-nil or we are not before or inside a word, and if skeleton-pair-filter-function returns nil, pairing is performed. Pairing is also prohibited if we are right after a quoting character such as backslash.

If a match is found in skeleton-pair-alist, that is inserted, else the defaults are used. These are (), [], {}, <> and (grave accent, apostrophe) for the paired ones, and the same character twice for the others.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/skeleton.el.gz
;;;###autoload
(defun skeleton-pair-insert-maybe (arg)
  "Insert the character you type ARG times.

With no ARG, if `skeleton-pair' is non-nil, pairing can occur.  If the region
is visible the pair is wrapped around it depending on `skeleton-autowrap'.
Else, if `skeleton-pair-on-word' is non-nil or we are not before or inside a
word, and if `skeleton-pair-filter-function' returns nil, pairing is performed.
Pairing is also prohibited if we are right after a quoting character
such as backslash.

If a match is found in `skeleton-pair-alist', that is inserted, else
the defaults are used.  These are (), [], {}, <> and (grave
accent, apostrophe) for the paired ones, and the same character
twice for the others."
  (interactive "*P")
  (if (or arg (not skeleton-pair))
      (self-insert-command (prefix-numeric-value arg))
    (let* ((mark (and skeleton-autowrap
		      (or (eq last-command 'mouse-drag-region)
			  (and transient-mark-mode mark-active))))
	   (char last-command-event)
	   (skeleton (or (assq char skeleton-pair-alist)
			 (assq char skeleton-pair-default-alist)
			 `(,char _ ,char))))
      (if (or (memq (char-syntax (preceding-char)) '(?\\ ?/))
	      (and (not mark)
		   (or overwrite-mode
		       (if (not skeleton-pair-on-word) (looking-at "\\w"))
		       (funcall skeleton-pair-filter-function))))
	  (self-insert-command (prefix-numeric-value arg))
	;; Newlines not desirable for inserting pairs.  See bug#16138.
	(let ((skeleton-end-newline nil))
	  (skeleton-insert (cons nil skeleton) (if mark -1)))))))