* Printing list to buffer
@ 2022-10-21 22:20 Heime via Users list for the GNU Emacs text editor
2022-10-22 6:48 ` Jean Louis
0 siblings, 1 reply; 2+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2022-10-21 22:20 UTC (permalink / raw)
To: Heime via Users list for the GNU Emacs text editor
I am using the function to print a lisp object to a buffer, but the printing is not happening.
I set a list
(defvar names '("Paul" "Peter"))
(viewer names)
--------------------
(defun viewer (bufrn obj)
"Prints object obj to a buffer."
(with-current-buffer (get-buffer-create bufrn)
(org-mode) (princ obj))
(pop-to-buffer bufrn))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Printing list to buffer
2022-10-21 22:20 Printing list to buffer Heime via Users list for the GNU Emacs text editor
@ 2022-10-22 6:48 ` Jean Louis
0 siblings, 0 replies; 2+ messages in thread
From: Jean Louis @ 2022-10-22 6:48 UTC (permalink / raw)
To: Heime; +Cc: Heime via Users list for the GNU Emacs text editor
* Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2022-10-22 02:33]:
> I am using the function to print a lisp object to a buffer, but the printing is not happening.
>
> I set a list
>
> (defvar names '("Paul" "Peter"))
>
> (viewer names)
>
> --------------------
>
> (defun viewer (bufrn obj)
>
> "Prints object obj to a buffer."
> (with-current-buffer (get-buffer-create bufrn)
>
> (org-mode) (princ obj))
>
> (pop-to-buffer bufrn))
I have this function:
(defun rcd-pop-to-report (string &optional buffer-name map place refresh truncate return-function)
"Pop the new buffer and inserts STRING.
Quits with `q' if necessary.
BUFFER-NAME is optional.
It will destroy the buffer before display of report."
(let ((buffer (or buffer-name "*RCD Report*")))
(when (buffer-live-p (get-buffer buffer))
(kill-buffer (get-buffer buffer)))
(save-excursion
(pop-to-buffer buffer)
(let ((word-wrap truncate))
(when word-wrap (toggle-truncate-lines 1))
(setq rcd-db-current-table (when (listp place) (cdr (assoc "table" place))))
(setq rcd-db-current-column (when (listp place) (cdr (assoc "column" place))))
(setq rcd-db-current-table-id (when (listp place) (cdr (assoc "table-id" place))))
(setq rcd-tabulated-refresh-function refresh)
(setq rcd-current-return-function return-function)
(insert string)
(goto-char 1)
(cond (map (use-local-map map))
(t (local-set-key (kbd "q") 'kill-buffer-and-window)))
(read-only-mode 1)))))
Then maybe I can shorten it:
(defun rcd-pop-to-report (string &optional buffer-name mode)
"Pop the new buffer and inserts STRING.
BUFFER-NAME is optional.
MODE is optional, shall be symbol of the mode.
Funcation will destroy the buffer before display of report."
(let ((buffer (or buffer-name "*RCD Report*")))
(when (buffer-live-p (get-buffer buffer))
(kill-buffer (get-buffer buffer)))
(save-excursion
(pop-to-buffer buffer)
(insert string)
(goto-char 1)
(cond (mode (funcall mode))
(t (read-only-mode 1))))))
(rcd-pop-to-report "** Hello there" nil 'org-mode)
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-22 6:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-21 22:20 Printing list to buffer Heime via Users list for the GNU Emacs text editor
2022-10-22 6:48 ` Jean Louis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).