* Make new buffers into new frames @ 2024-09-29 7:40 Heime 2024-09-29 12:44 ` Heime 0 siblings, 1 reply; 12+ messages in thread From: Heime @ 2024-09-29 7:40 UTC (permalink / raw) To: Heime via Users list for the GNU Emacs text editor I want to display the user named buffer when calling buffer-into-frame into a new frame. The buffer will have a button, which when pressed another buffer will be made to display my-message, which is some text. I also want my-message to be displayed in a buffer and in the same new frame. (defun display-message (my-message &optional bfrn) "Display textual message into the buffer BFRN." (let* ( (bfname (or bfrn "Info")) (dbuffer (get-buffer-create (concat "𒆳 " bfname))) ) (with-current-buffer dbuffer (erase-buffer) (insert my-message) (goto-char (point-min))) (display-buffer dbuffer))) ;; ------------------------------------------------------- (defun buffer-into-frame (&optional bfrn) "TODO" (interactive (list (let ( (rqmatch nil) (cseq '("Default" "Torium")) ) (completing-read " Display Name: " cseq nil rqmatch "Selection Buffer")))) (let* ( (bfname (or bfrn "S_election Buffer")) (dbuffer (get-buffer-create (concat "𒆳 " bfname))) ) (with-current-buffer dbuffer (erase-buffer) ;; Insert a button that shows the info when pressed (insert-button " - " 'action (display-message my-message "Info Buffer") 'follow-link t) (insert " Running Non-Interactive Commands"))) ) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-29 7:40 Make new buffers into new frames Heime @ 2024-09-29 12:44 ` Heime 2024-09-29 17:15 ` tomas 0 siblings, 1 reply; 12+ messages in thread From: Heime @ 2024-09-29 12:44 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor On Sunday, September 29th, 2024 at 7:40 PM, Heime <heimeborgia@protonmail.com> wrote: > I want to display the user named buffer when calling buffer-into-frame into > a new frame. The buffer will have a button, which when pressed another buffer > will be made to display my-message, which is some text. > > I also want my-message to be displayed in a buffer and in the same new frame. > > (defun display-message (my-message &optional bfrn) > "Display textual message into the buffer BFRN." > > (let* ( (bfname (or bfrn "Info")) > (dbuffer (get-buffer-create (concat "𒆳 " bfname))) ) > > (with-current-buffer dbuffer > (erase-buffer) > (insert my-message) > (goto-char (point-min))) > > (display-buffer dbuffer))) > > ;; ------------------------------------------------------- > > (defun buffer-into-frame (&optional bfrn) > "TODO" > > (interactive > (list (let ( (rqmatch nil) > (cseq '("Default" "Torium")) ) > (completing-read " Display Name: " cseq nil rqmatch "Selection Buffer")))) > > (let* ( (bfname (or bfrn "S_election Buffer")) > (dbuffer (get-buffer-create (concat "𒆳 " bfname))) ) > > (with-current-buffer dbuffer > (erase-buffer) > > ;; Insert a button that shows the info when pressed > (insert-button " - " > 'action (display-message my-message "Info Buffer") > 'follow-link t) > > (insert " Running Non-Interactive Commands"))) ) Have made a dedicated frame frame-display-unit. With trm-display-info used to display a message, and trm-button-choices handling the button choices. But things go wrong when I press the button with (invalid-function #<window 14 on 𒆳 Info>) (defvar frame-display-unit nil "Dedicated frame for displaying specific buffers.") ;; ----------------------------------------------------------- (defun trm-display-info (message &optional bfrn) "Display textual message into the buffer BFRN." (let* ( (bfname (or bfrn "Display Button Choice")) (dbuffer (get-buffer-create (concat "𒆳 " bfname))) ) (with-current-buffer dbuffer (erase-buffer) (insert message) (goto-char (point-min))) (display-buffer dbuffer) )) ;; ---------------------------------------------------- (defun trm-button-choices (&optional bfrn) "TODO" (interactive (list (let ( (rqmatch nil) (cseq '("Default" "Choices")) ) (completing-read " Display Name: " cseq nil rqmatch "Choices")))) (let* ( (bfname (or bfrn "Choices")) (dbuffer (get-buffer-create (concat "𒆳 " bfname))) ) ;; Initialize the dedicated frame if it doesn't exist (unless (frame-live-p frame-display-unit) (setq frame-display-unit (make-frame '((name . "Frame Display Unit"))))) (with-current-buffer dbuffer (erase-buffer) ;; Insert a button that shows the info when pressed (insert-button " - " 'action (trm-display-info my-message "Info") 'follow-link t) (insert " Running Non-Interactive Commands")) ;; Display the buffer in the dedicated frame (select-frame-set-input-focus frame-display-unit) (set-window-buffer (frame-selected-window frame-display-unit) dbuffer))) ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-29 12:44 ` Heime @ 2024-09-29 17:15 ` tomas 2024-09-29 19:16 ` Heime 0 siblings, 1 reply; 12+ messages in thread From: tomas @ 2024-09-29 17:15 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor [-- Attachment #1: Type: text/plain, Size: 1097 bytes --] On Sun, Sep 29, 2024 at 12:44:04PM +0000, Heime wrote: > > On Sunday, September 29th, 2024 at 7:40 PM, Heime <heimeborgia@protonmail.com> wrote: > > > I want to display the user named buffer when calling buffer-into-frame into > > a new frame. The buffer will have a button, which when pressed another buffer > > will be made to display my-message, which is some text. You should really, really try to understand how Lisp "works". People keep saying that, and you seem to ignore it. Once your programs get one level more complex, you might be unable to debug them. > > I also want my-message to be displayed in a buffer and in the same new frame. When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop. [1] [snip] > > ;; Insert a button that shows the info when pressed > > (insert-button " - " > > 'action (display-message my-message "Info Buffer") > > 'follow-link t) [snap] And now explain to us what kind of thing the function "insert-button" expects after the symbol 'action. Cheers -- t [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-29 17:15 ` tomas @ 2024-09-29 19:16 ` Heime 2024-09-29 19:22 ` tomas 0 siblings, 1 reply; 12+ messages in thread From: Heime @ 2024-09-29 19:16 UTC (permalink / raw) To: tomas; +Cc: Heime via Users list for the GNU Emacs text editor Sent with Proton Mail secure email. On Monday, September 30th, 2024 at 5:15 AM, tomas@tuxteam.de <tomas@tuxteam.de> wrote: > On Sun, Sep 29, 2024 at 12:44:04PM +0000, Heime wrote: > > > On Sunday, September 29th, 2024 at 7:40 PM, Heime heimeborgia@protonmail.com wrote: > > > > I want to display the user named buffer when calling buffer-into-frame into > > > a new frame. The buffer will have a button, which when pressed another buffer > > > will be made to display my-message, which is some text. > > > You should really, really try to understand how Lisp "works". > People keep saying that, and you seem to ignore it. Once your > programs get one level more complex, you might be unable to > debug them. > > > > I also want my-message to be displayed in a buffer and in the same new frame. > > > When someone says "I want a programming language in which I need only > say what I wish done," give him a lollipop. [1] > > [snip] > > > > ;; Insert a button that shows the info when pressed > > > (insert-button " - " > > > 'action (display-message my-message "Info Buffer") > > > 'follow-link t) > > > [snap] > > And now explain to us what kind of thing the function "insert-button" > expects after the symbol 'action. There is not much information in the manual about it. In the section Button Properties, action states that it requires a function to call when the user invokes the button, which is passed the single argument button. By default this is ignore, which does nothing. Thus I would need a button type argument even though I would not use it. I just have a function that displays some text variable in some new buffer. As a general function, I do not want trm-display-info to include a button variable in its argument list. > Cheers > -- > t ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-29 19:16 ` Heime @ 2024-09-29 19:22 ` tomas 2024-09-29 19:31 ` Heime 0 siblings, 1 reply; 12+ messages in thread From: tomas @ 2024-09-29 19:22 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor [-- Attachment #1: Type: text/plain, Size: 539 bytes --] On Sun, Sep 29, 2024 at 07:16:22PM +0000, Heime wrote: [...] > > > > 'action (display-message my-message "Info Buffer") > > And now explain to us what kind of thing the function "insert-button" > > expects after the symbol 'action. > > There is not much information in the manual about it. In the section > Button Properties, action states that it requires a function Aha! A function. Now stop ten seconds: a function makes sense? Yes, kind of. To me at least. And now: what are you giving to it? Cheers -- t [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-29 19:22 ` tomas @ 2024-09-29 19:31 ` Heime 2024-09-30 4:41 ` tomas 0 siblings, 1 reply; 12+ messages in thread From: Heime @ 2024-09-29 19:31 UTC (permalink / raw) To: tomas; +Cc: Heime via Users list for the GNU Emacs text editor Sent with Proton Mail secure email. On Monday, September 30th, 2024 at 7:22 AM, tomas@tuxteam.de <tomas@tuxteam.de> wrote: > On Sun, Sep 29, 2024 at 07:16:22PM +0000, Heime wrote: > > [...] > > > > > > 'action (display-message my-message "Info Buffer") > > > > And now explain to us what kind of thing the function "insert-button" > > > expects after the symbol 'action. > > > > There is not much information in the manual about it. In the section > > Button Properties, action states that it requires a function > > > Aha! A function. Now stop ten seconds: a function makes sense? Yes, > kind of. To me at least. > > And now: what are you giving to it? I am currently giving it the command to print the text in some new buffer. I either have to make an intermediary function with only a button argument or a lambda function with one argument and then include within it the call to (display-message my-message "Info Buffer"). What do people do with the button argument ? Would I have to use it in some way ? > Cheers > -- > t ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-29 19:31 ` Heime @ 2024-09-30 4:41 ` tomas 2024-09-30 6:40 ` Heime 0 siblings, 1 reply; 12+ messages in thread From: tomas @ 2024-09-30 4:41 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor [-- Attachment #1: Type: text/plain, Size: 1498 bytes --] On Sun, Sep 29, 2024 at 07:31:07PM +0000, Heime wrote: > > > > > > Sent with Proton Mail secure email. > > On Monday, September 30th, 2024 at 7:22 AM, tomas@tuxteam.de <tomas@tuxteam.de> wrote: > > > On Sun, Sep 29, 2024 at 07:16:22PM +0000, Heime wrote: > > > > [...] > > > > > > > > 'action (display-message my-message "Info Buffer") > > > > > > And now explain to us what kind of thing the function "insert-button" > > > > expects after the symbol 'action. > > > > > > There is not much information in the manual about it. In the section > > > Button Properties, action states that it requires a function > > > > > > Aha! A function. Now stop ten seconds: a function makes sense? Yes, > > kind of. To me at least. > > > > And now: what are you giving to it? > > I am currently giving it the command to print the text in some new buffer. No. You are not. What does your lisp do when it "sees" the expression (+ 1 2) ...and what is the result? You put the expression (display-message my-message "Info Buffer") ...which gets evaluated on-the-spot, and returns... a window! (what you can confirm if you follow the code). So your insert-button invocation places a window in its 'action "place" and tries to call that window as if it were a function. This can't go well. Thus the error message. Once again. Try to wrap your head around the Lisp evaluation model. This will save you a lot of work long-term. Cheers -- t [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-30 4:41 ` tomas @ 2024-09-30 6:40 ` Heime 2024-09-30 9:13 ` Stephen Berman ` (2 more replies) 0 siblings, 3 replies; 12+ messages in thread From: Heime @ 2024-09-30 6:40 UTC (permalink / raw) To: tomas; +Cc: Heime via Users list for the GNU Emacs text editor On Monday, September 30th, 2024 at 4:41 PM, tomas@tuxteam.de <tomas@tuxteam.de> wrote: > On Sun, Sep 29, 2024 at 07:31:07PM +0000, Heime wrote: > > > Sent with Proton Mail secure email. > > > > On Monday, September 30th, 2024 at 7:22 AM, tomas@tuxteam.de tomas@tuxteam.de wrote: > > > > > On Sun, Sep 29, 2024 at 07:16:22PM +0000, Heime wrote: > > > > > > [...] > > > > > > > > > > 'action (display-message my-message "Info Buffer") > > > > > > > > And now explain to us what kind of thing the function "insert-button" > > > > > expects after the symbol 'action. > > > > > > > > There is not much information in the manual about it. In the section > > > > Button Properties, action states that it requires a function > > > > > > Aha! A function. Now stop ten seconds: a function makes sense? Yes, > > > kind of. To me at least. > > > > > > And now: what are you giving to it? > > > > I am currently giving it the command to print the text in some new buffer. > > > No. You are not. What does your lisp do when it "sees" the expression > > (+ 1 2) > > ...and what is the result? The result is 3, the value returned as the result of the entire expression. > You put the expression > > (display-message my-message "Info Buffer") > > ...which gets evaluated on-the-spot, and returns... a window! (what you can > confirm if you follow the code). So your insert-button invocation places a > window in its 'action "place" and tries to call that window as if it were a > function. This can't go well. > > Thus the error message. > > Once again. Try to wrap your head around the Lisp evaluation model. This will > save you a lot of work long-term. I understand. The expression (display-message my-message "Info Buffer") is used to display the contents of a buffer (dbuffer) in a window. The display-message function returns the window in which the buffer is displayed. Because of the last call. Because it evaluates the expression (display-buffer dbuffer), which returns the window that is displaying the buffer dbuffer. Then the correct way is 'action (lambda (button) (display-message my-message "Info Buffer")) Does one perform any operation with the button argument in the declared function or lambda ? > Cheers > -- > t ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-30 6:40 ` Heime @ 2024-09-30 9:13 ` Stephen Berman 2024-09-30 9:15 ` tomas 2024-09-30 9:29 ` Rudolf Schlatte 2 siblings, 0 replies; 12+ messages in thread From: Stephen Berman @ 2024-09-30 9:13 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor On Mon, 30 Sep 2024 06:40:42 +0000 Heime <heimeborgia@protonmail.com> wrote: [...] > Then the correct way is > > 'action (lambda (button) > (display-message my-message "Info Buffer")) > > Does one perform any operation with the button argument in the > declared function or lambda ? See (info "(elisp) Manipulating Buttons"), in particular: -- Function: button-activate button &optional use-mouse-action Call BUTTON's ‘action’ property (i.e., invoke the function that is the value of that property, passing it the single argument BUTTON). [...] However, since in your case the argument `button' is not used in the body of the function, if you enable lexical binding in the file containing it and byte-compile the file, you'll get a warning: "Unused lexical argument ‘button’". To avoid that warning, you can use e.g. `_button' (or just `_') as the argument (cf. (info "(elisp) Converting to Lexical Binding")). Steve Berman ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-30 6:40 ` Heime 2024-09-30 9:13 ` Stephen Berman @ 2024-09-30 9:15 ` tomas 2024-09-30 9:29 ` Rudolf Schlatte 2 siblings, 0 replies; 12+ messages in thread From: tomas @ 2024-09-30 9:15 UTC (permalink / raw) To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor [-- Attachment #1: Type: text/plain, Size: 950 bytes --] On Mon, Sep 30, 2024 at 06:40:42AM +0000, Heime wrote: > > > On Monday, September 30th, 2024 at 4:41 PM, tomas@tuxteam.de <tomas@tuxteam.de> wrote: [...] > I understand. The expression (display-message my-message "Info Buffer") is used > to display the contents of a buffer (dbuffer) in a window. > > The display-message function returns the window in which the buffer is displayed. > Because of the last call. Because it evaluates the expression (display-buffer dbuffer), > which returns the window that is displaying the buffer dbuffer. > > Then the correct way is > > 'action (lambda (button) > (display-message my-message "Info Buffer")) Bingo. > Does one perform any operation with the button argument in the > declared function or lambda ? I don't understand that question. Who is "one" and what do you mean by "any operation" [1]? Cheers [1] https://able2know.org/topic/252066-1 -- t [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-30 6:40 ` Heime 2024-09-30 9:13 ` Stephen Berman 2024-09-30 9:15 ` tomas @ 2024-09-30 9:29 ` Rudolf Schlatte 2024-09-30 19:32 ` Heime 2 siblings, 1 reply; 12+ messages in thread From: Rudolf Schlatte @ 2024-09-30 9:29 UTC (permalink / raw) To: help-gnu-emacs Heime <heimeborgia@protonmail.com> writes: [...] > > Then the correct way is > > 'action (lambda (button) > (display-message my-message "Info Buffer")) > > Does one perform any operation with the button argument in the > declared function or lambda ? The action does not need to be a lambda form, but can be a named function. If that function is supposed to handle button presses for multiple buttons, the button arguments lets it know which button was pressed. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Make new buffers into new frames 2024-09-30 9:29 ` Rudolf Schlatte @ 2024-09-30 19:32 ` Heime 0 siblings, 0 replies; 12+ messages in thread From: Heime @ 2024-09-30 19:32 UTC (permalink / raw) To: Rudolf Schlatte; +Cc: help-gnu-emacs Sent with Proton Mail secure email. On Monday, September 30th, 2024 at 9:29 PM, Rudolf Schlatte <rudi@constantly.at> wrote: > Heime heimeborgia@protonmail.com writes: > > [...] > > > Then the correct way is > > > > 'action (lambda (button) > > (display-message my-message "Info Buffer")) > > > > Does one perform any operation with the button argument in the > > declared function or lambda ? > > > The action does not need to be a lambda form, but can be a named > function. If that function is supposed to handle button presses for > multiple buttons, the button arguments lets it know which button was > pressed. Can the function associated with an action have more than a single button variable as argument, or is it always a single button argument ? ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-09-30 19:32 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-09-29 7:40 Make new buffers into new frames Heime 2024-09-29 12:44 ` Heime 2024-09-29 17:15 ` tomas 2024-09-29 19:16 ` Heime 2024-09-29 19:22 ` tomas 2024-09-29 19:31 ` Heime 2024-09-30 4:41 ` tomas 2024-09-30 6:40 ` Heime 2024-09-30 9:13 ` Stephen Berman 2024-09-30 9:15 ` tomas 2024-09-30 9:29 ` Rudolf Schlatte 2024-09-30 19:32 ` Heime
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.