help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make new buffers into new frames


From: Heime
Subject: Re: Make new buffers into new frames
Date: Sun, 29 Sep 2024 12:44:04 +0000

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)))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]