|
44 | 44 | (defconst auto-rename-tag--tag-regexp "<[^>]*" |
45 | 45 | "Tag regular expression to find tag position.") |
46 | 46 |
|
47 | | -(defvar-local auto-rename-tag--pre-command-activated nil |
48 | | - "Check if `pre-command-hook' called.") |
| 47 | +(defvar-local auto-rename-tag--before-action-activated nil |
| 48 | + "Check if `before-action' called.") |
| 49 | + |
| 50 | +(defvar-local auto-rename-tag--after-action-active nil |
| 51 | + "Check if `after-action' is currently called.") |
49 | 52 |
|
50 | 53 | (defvar-local auto-rename-tag--record-prev-word "" |
51 | | - "Record down the word in `pre-command-hook'.") |
| 54 | + "Record down the word in `before-action'.") |
52 | 55 |
|
53 | 56 |
|
54 | 57 | (defun auto-rename-tag--delete-tag-name () |
@@ -345,31 +348,35 @@ DIRECT can be either only 'backward and 'forward." |
345 | 348 |
|
346 | 349 | (defun auto-rename-tag--before-action () |
347 | 350 | "Before rename core action." |
348 | | - (setq auto-rename-tag--record-prev-word "") ; Reset record. |
349 | | - (setq auto-rename-tag--pre-command-activated nil) ; Reset flag. |
| 351 | + (unless auto-rename-tag--after-action-active |
| 352 | + (setq auto-rename-tag--record-prev-word "") ; Reset record. |
| 353 | + (setq auto-rename-tag--before-action-activated nil) ; Reset flag. |
350 | 354 |
|
351 | | - (when (and (not undo-in-progress) |
352 | | - (auto-rename-tag--inside-tag-p) |
353 | | - (not (auto-rename-tag--self-tag-p))) |
354 | | - (save-excursion |
355 | | - ;; Set active flag. |
356 | | - (setq auto-rename-tag--pre-command-activated t) |
| 355 | + (when (and (not undo-in-progress) |
| 356 | + (auto-rename-tag--inside-tag-p) |
| 357 | + (not (auto-rename-tag--self-tag-p))) |
| 358 | + (save-excursion |
| 359 | + ;; Set active flag. |
| 360 | + (setq auto-rename-tag--before-action-activated t) |
357 | 361 |
|
358 | | - (setq auto-rename-tag--record-prev-word (auto-rename-tag--get-tag-name-at-point)) |
| 362 | + (setq auto-rename-tag--record-prev-word (auto-rename-tag--get-tag-name-at-point)) |
359 | 363 |
|
360 | | - (when (string= auto-rename-tag--record-prev-word "/") |
361 | | - (setq auto-rename-tag--record-prev-word "")) |
| 364 | + (when (string= auto-rename-tag--record-prev-word "/") |
| 365 | + (setq auto-rename-tag--record-prev-word "")) |
362 | 366 |
|
363 | | - ;; Ensure `auto-rename-tag--record-prev-word' is something other than nil. |
364 | | - (unless auto-rename-tag--record-prev-word |
365 | | - (setq auto-rename-tag--record-prev-word ""))))) |
| 367 | + ;; Ensure `auto-rename-tag--record-prev-word' is something other than nil. |
| 368 | + (unless auto-rename-tag--record-prev-word |
| 369 | + (setq auto-rename-tag--record-prev-word "")))))) |
366 | 370 |
|
367 | 371 | (defun auto-rename-tag--after-action () |
368 | 372 | "After rename core action." |
369 | | - (when auto-rename-tag--pre-command-activated |
| 373 | + (when (and auto-rename-tag--before-action-activated |
| 374 | + (not auto-rename-tag--after-action-active)) |
370 | 375 | (save-excursion |
371 | | - (let ((is-end-tag nil) |
372 | | - (current-word "") (pair-tag-word "")) |
| 376 | + (let ((auto-rename-tag--after-action-active t) |
| 377 | + (is-end-tag nil) |
| 378 | + (current-word "") (pair-tag-word "") |
| 379 | + (inhibit-modification-hooks nil)) |
373 | 380 | ;; Goto the first character inside the tag. |
374 | 381 | (auto-rename-tag--goto-the-start-of-tag-name) |
375 | 382 |
|
|
0 commit comments