From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: New Package: sticky-shell Date: Mon, 12 Dec 2022 18:33:45 +0000 Message-ID: <87a63stqt2.fsf@posteo.net> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8542"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Andrew De Angelis Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 12 19:34:36 2022 Return-path: Envelope-to: ged-emacs-devel@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 1p4ndK-0001zJ-7v for ged-emacs-devel@m.gmane-mx.org; Mon, 12 Dec 2022 19:34:34 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p4nd2-0000mf-Me; Mon, 12 Dec 2022 13:34:16 -0500 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 1p4nca-0000bV-Rt for emacs-devel@gnu.org; Mon, 12 Dec 2022 13:34:07 -0500 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p4ncY-0000Vn-AX for emacs-devel@gnu.org; Mon, 12 Dec 2022 13:33:48 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id DC467240104 for ; Mon, 12 Dec 2022 19:33:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1670870023; bh=SYDl8FNFtQQILJ3orOQwDfoRQaKpcOI43wXrv/P10PU=; h=From:To:Cc:Subject:Date:From; b=f6U0iXPS1YIz+QfMAJQX6vEBCVoB/z4WD3PkC9xnAYpJ2L30uLbkpjFvdfBOrPAzu Pe0sC6eG5MiYyV2G0ZrTCZSzGDxSd34VO2C+SPWtu9+qkO6aycyu5tpvPS7JZyXJ67 7oiTMnI3w2rkphXx4ySQFBLPmfJKdI6YU0hLpQCGT4KcYvLvTCIVN/E8MD3E/2u5uY X3hGfY+gU5Ap4P/tkMlIObbe7gSU0wMwGwET+rv0q4qIoMKjxxN2oiwaGbvPIeFu98 mok58pmRPI0dNNXYw/x3O1SchGLmktcVKGZXl+/kEGY1T+OFDgsNKVVGWU/9VhXC3b jt6tjRbKx8O4g== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4NW9Hq1bgQz9rxY; Mon, 12 Dec 2022 19:33:43 +0100 (CET) In-Reply-To: (Andrew De Angelis's message of "Sun, 11 Dec 2022 19:05:26 -0500") Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301268 Archived-At: --=-=-= Content-Type: text/plain Andrew De Angelis writes: > Hello everyone and thanks for all your work. > I've made a new package that I would like to add to Elpa. I assume you are referring to GNU ELPA (the only where contributors have to sign the FSF CA?) > The package provides a minor mode that creates a header in a shell buffer. > The header shows the prompt above the top-visible line, allowing users to > keep track of what prompt generated which output, even with very large > multiple-line outputs. > The package also has some customization features that can be used to > determine which prompt to show in the header (it can be the latest-executed > prompt, etc), and the look of the header. Sounds interesting! > This is the git repo: https://github.com/andyjda/sticky-shell, with > additional info in the README and in the code's documentation. Here are a few commends: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/sticky-shell.el b/sticky-shell.el index 0fdc108..4d8aaa9 100644 --- a/sticky-shell.el +++ b/sticky-shell.el @@ -36,6 +36,8 @@ ;;; Code: (eval-when-compile + ;; Why are these only required during compilation? You appear to be + ;; using actual functions from these modules, not just macros. (require 'eshell) (require 'comint)) @@ -46,7 +48,6 @@ "Display a sticky header with latest shell-prompt." :group 'terminals) - (defcustom sticky-shell-get-prompt #'sticky-shell-prompt-above-visible "Function used by sticky-shell-mode to pick the prompt to show in the header. @@ -55,21 +56,23 @@ Available values are: `sticky-shell-latest-prompt', `sticky-shell-prompt-above-cursor', `sticky-shell-prompt-before-cursor' or you can write your own function and assign it to this variable." - :group 'sticky-shell - :type 'function) + :type '(choice (function-item :tag "Prompt above visible" sticky-shell-prompt-above-visible) + (function-item :tag "Latest prompt" sticky-shell-latest-prompt) + (function-item :tag "Prompt above cursor" sticky-shell-prompt-above-cursor) + (function-item :tag "Prompt before cursor" sticky-shell-prompt-before-cursor) + other)) (defcustom sticky-shell-prompt-modifiers - () + '() "List of functions modifying the prompt before it is displayed in the header. See `sticky-shell-modified-prompt' for an explanation on how the functions are applied." - :group 'sticky-shell :type 'list) (defun sticky-shell-prompt-current-line () "Return the current line and remove the trailing newline char." (let ((prompt (thing-at-point 'line))) - (aset prompt (- (length prompt) 1) 0) ; remove the newline ending char + (aset prompt (1- (length prompt)) 0) ; remove the newline ending char prompt)) (defun sticky-shell-latest-prompt () @@ -78,6 +81,8 @@ on how the functions are applied." (save-excursion (goto-char (point-max)) (forward-line -1) + ;; Perhaps you should pull this into a separate function, as the + ;; check appears quite often. Another idea, as the pattern appease quite similar in general, you could also (if (derived-mode-p 'eshell-mode) (eshell-previous-prompt 1) (comint-previous-prompt 1)) @@ -129,23 +134,25 @@ macro-expands to: (upcase (funcall sticky-shell-get-prompt)) \\='face \\='minibuffer-prompt)" + ;; The case distinction appears unnecessary (thread-first (foo)) is + ;; the same as (foo). (if sticky-shell-prompt-modifiers `(thread-first (funcall sticky-shell-get-prompt) ,@sticky-shell-prompt-modifiers) + ;; Perhaps it would be better/cleaner if + ;; `sticky-shell-prompt-modifiers' were a list of function that + ;; all get applied on the result of (funcall + ;; sticky-shell-get-prompt) in order? (funcall sticky-shell-get-prompt))) ;;;###autoload (define-minor-mode sticky-shell-mode "Minor mode to show the previous prompt as a sticky header." - :group 'comint :global nil - :lighter nil - (if sticky-shell-mode - (setq-local header-line-format - (list '(:eval - (sticky-shell-modified-prompt)))) - (setq-local header-line-format nil))) + (setq-local header-line-format + (and sticky-shell-mode + '((:eval (sticky-shell-modified-prompt)))))) (provide 'sticky-shell) ;;; sticky-shell.el ends here --=-=-= Content-Type: text/plain > Let me know if you have any questions and if there are any issues with > adding this to the Package Archive. (I do not have push-access to the git > repository) I don't think there should be any issue. The only thing I would recommend would be to consider adding an .elpaignore file to avoid adding the screenshots to the tarball. > Thank you! > > Best, > Andrew --=-=-=--