From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Luca Ferrari Newsgroups: gmane.emacs.help Subject: Re: help in writing function to pop indirect buffer Date: Thu, 7 Sep 2023 14:53:53 +0200 Message-ID: References: <63d50c2c.5d0a0220.cad7c.0cb0@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40173"; mail-complaints-to="usenet@ciao.gmane.io" To: Luca Ferrari , Bruno Barbier , help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 07 14:56:32 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qeEYi-000ACt-8f for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 07 Sep 2023 14:56:32 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeEWv-0000gX-9c; Thu, 07 Sep 2023 08:54:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qeEWs-0000fk-RM for help-gnu-emacs@gnu.org; Thu, 07 Sep 2023 08:54:38 -0400 Original-Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeEWm-0002hf-49 for help-gnu-emacs@gnu.org; Thu, 07 Sep 2023 08:54:38 -0400 Original-Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-26d49cf1811so668170a91.0 for ; Thu, 07 Sep 2023 05:54:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694091270; x=1694696070; darn=gnu.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=0FaVDy7b1RzbhhDUg9rM8NW8CDYUaSRRYLYMNj80ffg=; b=dp/vBbwa2YIwRplCYGKARCyXm358uZkaHWkC8zyjviC8gM9m3eAFpec3tN8wasDJzT nq2QxJWnY5WI2H6v7zd31JFTNAh/GnB7nvwhT5AMsyfyrxtOvzLKeMLy7QLoX1To38RN 8mwmhm8hvrItT/+aY7Xy/Ajj3hUMqq9pUKQcjdxMZCrgKhJ3Hycl9SX3oAsImpeDP26w 58ceaJjm8n6Bew02Zd8cpRwaFnD01plXvX0TZke/y2BQq7GX10Tex5wNwmmaX7psCPXM vnCSF8jkBNCRQZcnpz0jZmGxunZk+fFwZlrimKcPdUliIsnob7M9bw6vO32DCx0csU0n Iyuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694091270; x=1694696070; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0FaVDy7b1RzbhhDUg9rM8NW8CDYUaSRRYLYMNj80ffg=; b=A/PZ3Cdl5JSz9rXq7nTEy2lcL1T5coVVJQIMNpwpsAqMj1r2GR1A2CN8uEOt+ARd0X lwEwuFGCUYy0EgNN0rCUYW45vxoJdv0wngpfdyhMTsMj6T2YchkWuub5/5E61k6gT3Nq runmWC4FRtOCGbBZ3FT4aipyxZmlonxxZYbLcP7OeFpPbtmiEtb2u9+zYcqYACyCTEq/ baFiuMWVmuw4CUuPA1TJjix7Ns7yv7nc2sHii6OMUB7nhn45jzyZ5Ez4NWE8JFs/v6vt 0TXlyOfzZG5v/CovE2DX6i+Y4emMD9IaZS5z9ITe4eaph+1Fk2DOo65g3qSY00mFrD97 UeFw== X-Gm-Message-State: AOJu0Yx8IC1k5F71th/f6uTwX8f4pyNq/VpfqMxqzNvczq2TT5HrGcWy F3TuyDuz6e6tU/Jk2ZWWK/0IjbnS5rJg2u3kqHg= X-Google-Smtp-Source: AGHT+IE4J9NJpiMw3LM3PW3ljhyGDhJDRiA5qSkuVFAbG4c0p3We1kpX7mWibzMfVAjP9Mq7f1EwanbvXFcxEmUSJLs= X-Received: by 2002:a17:90b:124e:b0:26d:14cd:fb1a with SMTP id gx14-20020a17090b124e00b0026d14cdfb1amr16206320pjb.23.1694091270175; Thu, 07 Sep 2023 05:54:30 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=fluca1978@gmail.com; helo=mail-pj1-x102c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:145087 Archived-At: On Tue, Jan 31, 2023 at 8:39=E2=80=AFAM Jean Louis wrote= : > > * Luca Ferrari [2023-01-30 16:31]: > > On Sat, Jan 28, 2023 at 12:51 PM Bruno Barbier wr= ote: > > > In your use case, it might not be possible to use indirect buffers: t= he > > > 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 =E2=80=9Cx.el=E2=80=9D will result in emacs-lisp-mo= de. 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