all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Morgan Smith <Morgan.J.Smith@outlook.com>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 63778@debbugs.gnu.org
Subject: bug#63778: [PATCH] Use comint-pager in eshell
Date: Mon, 29 May 2023 02:23:31 -0400	[thread overview]
Message-ID: <DM5PR03MB3163EE8C8D3F3CF569F71754C54A9@DM5PR03MB3163.namprd03.prod.outlook.com> (raw)
In-Reply-To: <e99c9db9-e7f6-68ee-0895-a487e347eaaf@gmail.com> (Jim Porter's message of "Sun, 28 May 2023 19:41:40 -0700")

[-- Attachment #1: Type: text/plain, Size: 1534 bytes --]

Jim Porter <jporterbugs@gmail.com> writes:

>
> Ah, in that case, then I think you'd want to change the logic in esh-var.el so
> that, when 'comint-pager' is nil, $PAGER returns the real value of PAGER from
> the environment. Since this behavior is opt-in, I think it would be enough to
> just make this fix (and ignore the visual command stuff), though special
> handling for visual commands would still be nice to have.
>

I decided to work on this instead of sleeping so I apologize if these
patches are of poor quality.

I still haven't looked into how everything interacts with the visual
commands but it took some real effort (maybe because I'm tired :P) to
get what I got so far and I think it's good enough.

My main pain point was trying to figure out how to maintain the ability
to set/unset the PAGER variable.  These current patches allow you to
set/unset the PAGER variable iff you don't set comint-pager.  It even
allows you to do stuff like 'PAGER=cat git log' (see
eshell-handle-local-variables) without modifying buffer state (as it
should).  Maintaining those capabilities when comint-pager is set seems
very difficult so I gave up.

Trying to setq-local comint-pager in the set function might honestly be
a better user experience for those that set comint-pager but then doing
'PAGER=cat git log' would cause a permanent buffer local change.

So currently everything works 100% great and as expected if comint-pager
is nil.  If comint-pager is not-nil then you cannot set PAGER in a way
that will take any affect.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-infinite-loop-in-eshell-get-set-variable.patch --]
[-- Type: text/x-patch, Size: 1299 bytes --]

From 506849752916ac016457d891f4378d7d2116b0df Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Mon, 29 May 2023 02:04:42 -0400
Subject: [PATCH 1/2] Fix infinite loop in eshell-{get|set}-variable

* lisp/eshell/esh-var.el (eshell-get-variable, eshell-set-variable):
Short circuit if the name and target are the same.
---
 lisp/eshell/esh-var.el | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index 7dcaff1e24f..ecb0dfe274b 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -682,6 +682,8 @@ If QUOTED is non-nil, this was invoked inside double-quotes."
                 (funcall target indices)))))
          ((symbolp target)
           (eshell-apply-indices (symbol-value target) indices quoted))
+         ((and (equal name target))
+          (getenv target))
          (t
           (eshell-get-variable target indices quoted))))
     (unless (stringp name)
@@ -724,6 +726,8 @@ to a Lisp variable)."
          ((and eshell-prefer-lisp-variables
                (stringp target))
           (eshell-set-variable (intern target) value))
+         ((and (equal name target))
+          (setenv target value))
          (t
           (eshell-set-variable target value))))
     (cond
-- 
2.40.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Use-comint-pager-in-eshell.patch --]
[-- Type: text/x-patch, Size: 941 bytes --]

From 01a9f036988bfa3d00b9d837dbacb2666918bc2e Mon Sep 17 00:00:00 2001
From: Morgan Smith <Morgan.J.Smith@outlook.com>
Date: Mon, 29 May 2023 02:06:48 -0400
Subject: [PATCH 2/2] Use comint-pager in eshell

* lisp/eshell/esh-var.el (eshell-variable-aliases-list): Set $PAGER
environment variable from comint-pager variable
---
 lisp/eshell/esh-var.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lisp/eshell/esh-var.el b/lisp/eshell/esh-var.el
index ecb0dfe274b..b036024f065 100644
--- a/lisp/eshell/esh-var.el
+++ b/lisp/eshell/esh-var.el
@@ -162,6 +162,7 @@ if they are quoted with a backslash."
     ("COLUMNS" ,(lambda () (window-body-width nil 'remap)) t t)
     ("LINES" ,(lambda () (window-body-height nil 'remap)) t t)
     ("INSIDE_EMACS" eshell-inside-emacs t)
+    ("PAGER" (,(lambda () (or comint-pager (getenv "PAGER"))) . "PAGER") t t)
     ("UID" ,(lambda () (file-user-uid)) nil t)
 
     ;; for esh-ext.el
-- 
2.40.1


[-- Attachment #4: Type: text/plain, Size: 17 bytes --]


Thanks,

Morgan

  reply	other threads:[~2023-05-29  6:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-28 22:45 bug#63778: [PATCH] Use comint-pager in eshell Morgan Smith
2023-05-28 23:06 ` Jim Porter
     [not found]   ` <DM5PR03MB31631AA2F61C4C656FF6AFCFC54A9@DM5PR03MB3163.namprd03.prod.outlook.com>
2023-05-29  2:26     ` Morgan Smith
2023-05-29  2:41       ` Jim Porter
2023-05-29  6:23         ` Morgan Smith [this message]
2023-05-30  5:14           ` Jim Porter
2023-08-23 23:58             ` Jim Porter
2023-05-29 11:46   ` Eli Zaretskii

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=DM5PR03MB3163EE8C8D3F3CF569F71754C54A9@DM5PR03MB3163.namprd03.prod.outlook.com \
    --to=morgan.j.smith@outlook.com \
    --cc=63778@debbugs.gnu.org \
    --cc=jporterbugs@gmail.com \
    /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.