unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* help in writing function to pop indirect buffer
@ 2023-01-25 11:13 Luca Ferrari
  2023-01-25 17:55 ` Jean Louis
  2023-01-28 13:20 ` Jean Louis
  0 siblings, 2 replies; 10+ messages in thread
From: Luca Ferrari @ 2023-01-25 11:13 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-09-07 12:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-25 11:13 help in writing function to pop indirect buffer Luca Ferrari
2023-01-25 17:55 ` Jean Louis
2023-01-26  6:45   ` Emanuel Berg
2023-01-27 18:30   ` Bruno Barbier
     [not found]   ` <notmuch-sha1-03eb8baf922f469fd287c8e7e6f142e660e155d3>
2023-01-28 11:59     ` Bruno Barbier
2023-01-30 13:30       ` Luca Ferrari
2023-01-30 18:38         ` Bruno Barbier
2023-01-31  7:36         ` Jean Louis
2023-09-07 12:53           ` Luca Ferrari
2023-01-28 13:20 ` Jean Louis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).