help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

help in writing function to pop indirect buffer


From: Luca Ferrari
Subject: help in writing function to pop indirect buffer
Date: Wed, 25 Jan 2023 12:13:15 +0100

Hi all,
I'm still working on my need to edit Perl code within a region of an
SQL file, with all my configurations that apply to normal Perl
buffers.
One solution I came up is to launch an indirect buffer to edit the
region I need.
I've written the following:

(defun plperl-indirect-buffer-editing ()
  (interactive)
  (let ((plperl-buffer-name (generate-new-buffer-name "*plperl-indirect*"))
    (plperl-buffer-mode 'cperl-mode)
    (start (if mark-active (min (point) (mark)) (point)))
    (end   (if mark-active (max (point) (mark)) (point))))
    (pop-to-buffer (make-indirect-buffer (current-buffer) plperl-buffer-name))
    (funcall plperl-buffer-mode)
    (font-lock-mode)
    (narrow-to-region start end)
    (goto-char (point-min))
   (shrink-window-if-larger-than-buffer)))


This almost works, but when the indirect buffer is popped, I do not
have syntax highlight while I have indentation and apparently all the
other Perl things.
How can I turn on syntax highlight?

Another question: how can I let start and end to be bound to the
region between a defined tag like '$code$'? I thought about
word-search-forward and backward, but it seems ugly and not really
stable.

Thanks,
Luca



reply via email to

[Prev in Thread] Current Thread [Next in Thread]