mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-10 00:00:39 -08:00
* lisp/skeleton.el: Use lexical-binding
(skeleton-proxy-new): Use `use-region`.
This commit is contained in:
parent
33b293b41b
commit
e038a7571d
1 changed files with 51 additions and 47 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
;;; skeleton.el --- Lisp language extension for writing statement skeletons
|
;;; skeleton.el --- Lisp language extension for writing statement skeletons -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Copyright (C) 1993-1996, 2001-2020 Free Software Foundation, Inc.
|
;; Copyright (C) 1993-1996, 2001-2020 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
|
@ -155,8 +155,7 @@ of `str' whereas the skeleton's interactor is then ignored."
|
||||||
(prefix-numeric-value (or arg
|
(prefix-numeric-value (or arg
|
||||||
current-prefix-arg))
|
current-prefix-arg))
|
||||||
(and skeleton-autowrap
|
(and skeleton-autowrap
|
||||||
(or (eq last-command 'mouse-drag-region)
|
(use-region-p)
|
||||||
(and transient-mark-mode mark-active))
|
|
||||||
;; Deactivate the mark, in case one of the
|
;; Deactivate the mark, in case one of the
|
||||||
;; elements of the skeleton is sensitive
|
;; elements of the skeleton is sensitive
|
||||||
;; to such situations (e.g. it is itself a
|
;; to such situations (e.g. it is itself a
|
||||||
|
|
@ -259,12 +258,14 @@ available:
|
||||||
(goto-char (car skeleton-regions))
|
(goto-char (car skeleton-regions))
|
||||||
(setq skeleton-regions (cdr skeleton-regions)))
|
(setq skeleton-regions (cdr skeleton-regions)))
|
||||||
(let ((beg (point))
|
(let ((beg (point))
|
||||||
skeleton-modified skeleton-point resume: help input v1 v2)
|
skeleton-modified skeleton-point) ;; resume:
|
||||||
|
(with-suppressed-warnings ((lexical help input v1 v2))
|
||||||
|
(dlet (help input v1 v2)
|
||||||
(setq skeleton-positions nil)
|
(setq skeleton-positions nil)
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(cl-progv
|
(cl-progv
|
||||||
(mapcar #'car skeleton-further-elements)
|
(mapcar #'car skeleton-further-elements)
|
||||||
(mapcar (lambda (x) (eval (cadr x))) skeleton-further-elements)
|
(mapcar (lambda (x) (eval (cadr x) t)) skeleton-further-elements)
|
||||||
(skeleton-internal-list skeleton str))
|
(skeleton-internal-list skeleton str))
|
||||||
(or (eolp) (not skeleton-end-newline) (newline-and-indent))
|
(or (eolp) (not skeleton-end-newline) (newline-and-indent))
|
||||||
(run-hooks 'skeleton-end-hook)
|
(run-hooks 'skeleton-end-hook)
|
||||||
|
|
@ -275,7 +276,7 @@ available:
|
||||||
(goto-char beg)
|
(goto-char beg)
|
||||||
(recenter 0)))
|
(recenter 0)))
|
||||||
(if skeleton-point
|
(if skeleton-point
|
||||||
(goto-char skeleton-point))))))
|
(goto-char skeleton-point))))))))
|
||||||
|
|
||||||
(defun skeleton-read (prompt &optional initial-input recursive)
|
(defun skeleton-read (prompt &optional initial-input recursive)
|
||||||
"Function for reading a string from the minibuffer within skeletons.
|
"Function for reading a string from the minibuffer within skeletons.
|
||||||
|
|
@ -328,14 +329,17 @@ automatically, and you are prompted to fill in the variable parts.")))
|
||||||
(signal 'quit t)
|
(signal 'quit t)
|
||||||
prompt))
|
prompt))
|
||||||
|
|
||||||
(defun skeleton-internal-list (skeleton-il &optional str recursive)
|
(defun skeleton-internal-list (skeleton &optional str recursive)
|
||||||
(let* ((start (line-beginning-position))
|
(let* ((start (line-beginning-position))
|
||||||
(column (current-column))
|
(column (current-column))
|
||||||
(line (buffer-substring start (line-end-position)))
|
(line (buffer-substring start (line-end-position)))
|
||||||
|
(skeleton-il skeleton)
|
||||||
opoint)
|
opoint)
|
||||||
(or str
|
(with-suppressed-warnings ((lexical str))
|
||||||
(setq str `(setq str
|
(dlet ((str (or str
|
||||||
(skeleton-read ',(car skeleton-il) nil ,recursive))))
|
`(setq str
|
||||||
|
(skeleton-read ',(car skeleton-il)
|
||||||
|
nil ,recursive)))))
|
||||||
(when (and (eq (cadr skeleton-il) '\n) (not recursive)
|
(when (and (eq (cadr skeleton-il) '\n) (not recursive)
|
||||||
(save-excursion (skip-chars-backward " \t") (bolp)))
|
(save-excursion (skip-chars-backward " \t") (bolp)))
|
||||||
(setq skeleton-il (cons nil (cons '> (cddr skeleton-il)))))
|
(setq skeleton-il (cons nil (cons '> (cddr skeleton-il)))))
|
||||||
|
|
@ -357,7 +361,7 @@ automatically, and you are prompted to fill in the variable parts.")))
|
||||||
(if (cdr quit)
|
(if (cdr quit)
|
||||||
(setq skeleton-il ()
|
(setq skeleton-il ()
|
||||||
recursive nil)
|
recursive nil)
|
||||||
(signal 'quit 'recursive)))))))
|
(signal 'quit 'recursive)))))))))
|
||||||
;; maybe continue loop or go on to next outer resume: section
|
;; maybe continue loop or go on to next outer resume: section
|
||||||
(if (eq recursive 'quit)
|
(if (eq recursive 'quit)
|
||||||
(signal 'quit 'recursive)
|
(signal 'quit 'recursive)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue