diff options
| author | Gregory Heytings | 2022-11-26 22:38:12 +0000 |
|---|---|---|
| committer | Gregory Heytings | 2022-11-26 23:38:40 +0100 |
| commit | 321d4e61551a0f6dfb1abfc0b54e6177735bde58 (patch) | |
| tree | a774e7961eb13fae476ad678201f654e586c1d37 /src | |
| parent | 1bf0b72eb758440bc4571ebcb49ef0a59f37e51a (diff) | |
| download | emacs-321d4e61551a0f6dfb1abfc0b54e6177735bde58.tar.gz emacs-321d4e61551a0f6dfb1abfc0b54e6177735bde58.zip | |
Minor improvements for locked narrowing
* src/editfns.c (narrowing_lock_pop): Clarify comment, replace
assertion by return.
(narrowing_locks_restore): Add comments.
* lisp/subr.el (with-narrowing, internal--with-narrowing):
Simplify, use a single helper function with an optional argument.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/editfns.c b/src/editfns.c index 5bfb0b86d14..e99a007a70c 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -2712,12 +2712,14 @@ narrowing_lock_push (Lisp_Object buf, Lisp_Object lock) | |||
| 2712 | XCAR (XCDR (buffer_locks))))); | 2712 | XCAR (XCDR (buffer_locks))))); |
| 2713 | } | 2713 | } |
| 2714 | 2714 | ||
| 2715 | /* Remove the innermost lock in BUF from the narrowing_lock alist. */ | 2715 | /* Remove the innermost lock in BUF from the narrowing_lock alist. |
| 2716 | Do nothing if BUF is not in narrowing_lock. */ | ||
| 2716 | static void | 2717 | static void |
| 2717 | narrowing_lock_pop (Lisp_Object buf) | 2718 | narrowing_lock_pop (Lisp_Object buf) |
| 2718 | { | 2719 | { |
| 2719 | Lisp_Object buffer_locks = assq_no_quit (buf, narrowing_locks); | 2720 | Lisp_Object buffer_locks = assq_no_quit (buf, narrowing_locks); |
| 2720 | eassert (! NILP (buffer_locks)); | 2721 | if (NILP (buffer_locks)) |
| 2722 | return; | ||
| 2721 | if (EQ (narrowing_lock_peek_tag (buf), Qoutermost_narrowing)) | 2723 | if (EQ (narrowing_lock_peek_tag (buf), Qoutermost_narrowing)) |
| 2722 | narrowing_locks = Fdelq (Fassoc (buf, narrowing_locks, Qnil), | 2724 | narrowing_locks = Fdelq (Fassoc (buf, narrowing_locks, Qnil), |
| 2723 | narrowing_locks); | 2725 | narrowing_locks); |
| @@ -2779,8 +2781,12 @@ narrowing_locks_restore (Lisp_Object buf_and_saved_locks) | |||
| 2779 | if (NILP (buf_and_saved_locks)) | 2781 | if (NILP (buf_and_saved_locks)) |
| 2780 | return; | 2782 | return; |
| 2781 | Lisp_Object buf = XCAR (buf_and_saved_locks); | 2783 | Lisp_Object buf = XCAR (buf_and_saved_locks); |
| 2784 | /* This cannot fail when buf_and_saved_locks was returned by | ||
| 2785 | narrowing_locks_save. */ | ||
| 2782 | eassert (BUFFERP (buf)); | 2786 | eassert (BUFFERP (buf)); |
| 2783 | Lisp_Object saved_locks = XCDR (buf_and_saved_locks); | 2787 | Lisp_Object saved_locks = XCDR (buf_and_saved_locks); |
| 2788 | /* This cannot fail when buf_and_saved_locks was returned by | ||
| 2789 | narrowing_locks_save. */ | ||
| 2784 | eassert (! NILP (saved_locks)); | 2790 | eassert (! NILP (saved_locks)); |
| 2785 | Lisp_Object current_locks = assq_no_quit (buf, narrowing_locks); | 2791 | Lisp_Object current_locks = assq_no_quit (buf, narrowing_locks); |
| 2786 | if (! NILP (current_locks)) | 2792 | if (! NILP (current_locks)) |