all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luca Ferrari <fluca1978@gmail.com>
To: Luca Ferrari <fluca1978@gmail.com>,
	Bruno Barbier <brubar.cs@gmail.com>,
	 help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: Re: help in writing function to pop indirect buffer
Date: Thu, 7 Sep 2023 14:53:53 +0200	[thread overview]
Message-ID: <CAKoxK+4wRT=scJab9MniKD68unwuCtu3f7uhADDF01AuDisGbQ@mail.gmail.com> (raw)
In-Reply-To: <Y9jFDVP8sL98vw5L@protected.localdomain>

On Tue, Jan 31, 2023 at 8:39 AM Jean Louis <bugs@gnu.support> wrote:
>
> * Luca Ferrari <fluca1978@gmail.com> [2023-01-30 16:31]:
> > On Sat, Jan 28, 2023 at 12:51 PM Bruno Barbier <brubar.cs@gmail.com> wrote:
> > > In your use case, it might not be possible to use indirect buffers: the
> > > base buffer and the indirect buffer share the same text and its
> > > properties, and, syntax highlighting is mostly done using text
> > > properties.
> > >
> >
> > Gosh!
> > I've tested that if I enable cperl-mode in the original buffer, then
> > the indirect buffer inherits the syntax highligthing also for new
> > code.
>
> I gave you reference:
>
> EmacsWiki: Indirect Buffers:
> https://www.emacswiki.org/emacs/IndirectBuffers
>
> Where it says:
> --------------
>
> It seems one can also set the mode from a fake buffer-file-name (using
> auto-mode-alist in the usual way). At least with Emacs v20. So a
> fake-file-name of say “x.el” will result in emacs-lisp-mode.

I had some time to try over again, and apparently this is working fine:

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

Note that without the funcall plperl-buffer-mode and without adding
the fake extension to the buffer name, the perl mode is not selected.
I'm not fully satisfied however, I need to work on this a little more.

Thanks,
Luca



  reply	other threads:[~2023-09-07 12:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-01-28 13:20 ` Jean Louis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKoxK+4wRT=scJab9MniKD68unwuCtu3f7uhADDF01AuDisGbQ@mail.gmail.com' \
    --to=fluca1978@gmail.com \
    --cc=brubar.cs@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.