[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/idlwave 462aa84be4 004/360: (idlwave-surround): Added c
From: |
ELPA Syncer |
Subject: |
[elpa] externals/idlwave 462aa84be4 004/360: (idlwave-surround): Added callback hook for when the previous character |
Date: |
Sun, 28 Apr 2024 00:59:02 -0400 (EDT) |
branch: externals/idlwave
commit 462aa84be4da94f729fc75c4784d087aceaf258d
Author: jdsmith <jdsmith>
Commit: jdsmith <jdsmith>
(idlwave-surround): Added callback hook for when the previous character
matches ESCHAPE-CHARS, to support -> padding inside of the > key
binding.
(idlwave-close-block): Added fix to set `last-abbrev-location' by hand
before inserting "end".
---
idlwave.el | 82 +++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 49 insertions(+), 33 deletions(-)
diff --git a/idlwave.el b/idlwave.el
index 6543040c71..eb954e1109 100644
--- a/idlwave.el
+++ b/idlwave.el
@@ -5,7 +5,7 @@
;; Chris Chase <chase@att.com>
;; Maintainer: J.D. Smith <jdsmith@alum.mit.edu>
;; Version: VERSIONTAG
-;; Date: $Date: 2001/12/05 21:26:23 $
+;; Date: $Date: 2001/12/06 18:18:27 $
;; Keywords: languages
;; This file is part of GNU Emacs.
@@ -1498,7 +1498,7 @@ KEY in `idlwave-mode-map' by defining an anonymous
function calling
`self-insert-command' followed by CMD. If KEY contains more than one
character a binding will only be set if SELECT is 'both.
-(KEY . CMD\ is also placed in the `idlwave-indent-expand-table',
+\(KEY . CMD\) is also placed in the `idlwave-indent-expand-table',
replacing any previous value for KEY. If a binding is not set then it
will instead be placed in `idlwave-indent-action-table'.
@@ -1616,8 +1616,10 @@ Capitalize system variables - action only
;; Automatically add spaces for the following characters
(idlwave-action-and-binding "&" '(idlwave-surround -1 -1))
(idlwave-action-and-binding "<" '(idlwave-surround -1 -1))
-(idlwave-action-and-binding ">" '(idlwave-surround -1 -1 '(?-)))
-(idlwave-action-and-binding "->" '(idlwave-surround -1 -1 nil 2))
+;; Binding works for both > and ->, by changing the length of the token.
+(idlwave-action-and-binding ">" '(idlwave-surround -1 -1 '(?-) 1
+ 'idlwave-gtr-pad-hook))
+(idlwave-action-and-binding "->" '(idlwave-surround -1 -1 nil 2) t)
(idlwave-action-and-binding "," '(idlwave-surround 0 -1))
;; Automatically add spaces to equal sign if not keyword
(idlwave-action-and-binding "=" '(idlwave-expand-equal -1 -1))
@@ -2147,10 +2149,15 @@ Also checks if the correct end statement has been used."
(bolp))
(let ((idlwave-show-block nil))
(newline-and-indent)))
- (insert "end")
- (idlwave-show-begin))
+ (let ((last-abbrev-location (point))) ; for upcasing
+ (insert "end")
+ (idlwave-show-begin)))
-(defun idlwave-surround (&optional before after escape-chars length)
+(defun idlwave-gtr-pad-hook (char)
+ "Let the > symbol expand around -> if present."
+ (setq length 2))
+
+(defun idlwave-surround (&optional before after escape-chars length ec-hook)
"Surround the LENGTH characters before point with blanks.
LENGTH defaults to 1.
Optional arguments BEFORE and AFTER affect the behavior before and
@@ -2166,32 +2173,41 @@ The function does nothing if any of the following
conditions is true:
- the character before point is inside a string or comment
- the char preceeding the string to be surrounded is a member of ESCAPE-CHARS.
This hack is used to avoid padding of `>' when it is part of
- the '->' operator. In this case, ESCAPE-CHARS would be '(?-)."
-
- (setq length (or length 1)) ; establish a default for LENGTH
-
- (when (and idlwave-surround-by-blank
- (not (idlwave-quoted))
- (not (memq (char-after (- (point) (1+ length))) escape-chars)))
- (backward-char length)
- (save-restriction
- (let ((here (point)))
- (skip-chars-backward " \t")
- (if (bolp)
- ;; avoid clobbering indent
- (progn
- (move-to-column (idlwave-calculate-indent))
- (if (<= (point) here)
- (narrow-to-region (point) here))
- (goto-char here)))
- (idlwave-make-space before))
- (skip-chars-forward " \t"))
- (forward-char length)
- (idlwave-make-space after)
- ;; Check to see if the line should auto wrap
- (if (and (equal (char-after (1- (point))) ?\ )
- (> (current-column) fill-column))
- (funcall auto-fill-function))))
+ the '->' operator. In this case, ESCAPE-CHARS would be '(?-).
+
+If a function is passed in EC-HOOK, and an ESCAPE-CHARS match occurs,
+it will be called with a single argument: the preceding character.
+The idlwave-surround will run as usual if EC-HOOK returns non-nil.
+EC-HOOK should not move the point, and can change the let-bound
+`length' variable to change the length of the token to be padded."
+ (when (and idlwave-surround-by-blank (not (idlwave-quoted)))
+ (let* ((length (or length 1)) ; establish a default for LENGTH
+ (prev-char (char-after (- (point) (1+ length))))
+ (ec-halt nil))
+ (if (memq prev-char escape-chars)
+ (if (fboundp ec-hook)
+ (setq ec-halt (null (funcall ec-hook prev-char)))
+ (setq ec-halt t)))
+ (unless ec-halt
+ (backward-char length)
+ (save-restriction
+ (let ((here (point)))
+ (skip-chars-backward " \t")
+ (if (bolp)
+ ;; avoid clobbering indent
+ (progn
+ (move-to-column (idlwave-calculate-indent))
+ (if (<= (point) here)
+ (narrow-to-region (point) here))
+ (goto-char here)))
+ (idlwave-make-space before))
+ (skip-chars-forward " \t"))
+ (forward-char length)
+ (idlwave-make-space after)
+ ;; Check to see if the line should auto wrap
+ (if (and (equal (char-after (1- (point))) ?\ )
+ (> (current-column) fill-column))
+ (funcall auto-fill-function))))))
(defun idlwave-make-space (n)
"Make space at point.
- [elpa] externals/idlwave e9d19083b8 279/360: Check for idl_catalog.xml directly., (continued)
- [elpa] externals/idlwave e9d19083b8 279/360: Check for idl_catalog.xml directly., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 985427dd6a 274/360: Calculate beginning/end of commented paragraphs., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave ed1c40082b 264/360: Finish defun (was not)., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 5d7b645a67 262/360: Comments, whitespace, and typos. Boring., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave bc3cbb8b06 288/360: Avoid using cl macros., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 3932828c57 285/360: Don't use integers as anchors anymore., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 50c75e98ca 266/360: Use custom face for debug stop line, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave cc80618cbe 348/360: port from README, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 90b181e64e 297/360: Update XML scanning for more recent IDL versions:, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 6c9137c2da 324/360: Run hooks later and wait for initial commands., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 462aa84be4 004/360: (idlwave-surround): Added callback hook for when the previous character,
ELPA Syncer <=
- [elpa] externals/idlwave 58078a3f5a 006/360: Cleaned ec-hook formulation in idlwave-surround., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 177b0e4547 042/360: minor doc updates., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 6cd69cfb75 054/360: XEmacs Package bundling code included., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave e079639d57 073/360: *** empty log message ***, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 1a8845034c 070/360:, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 40b446a90e 078/360: - Slight update for XEmacs, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 00f3758733 083/360: - Initial check-in., ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 1ecae9e4c5 080/360: - Fixed non-edebug entering when stepping to new routines after a, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave cbc2128b09 081/360: - Follow savannah fix, ELPA Syncer, 2024/04/28
- [elpa] externals/idlwave 629d2ce5ae 085/360: - Make beg- and end- unit-reg use definitions starting on a line., ELPA Syncer, 2024/04/28