From: Jean Louis <bugs@gnu.support>
To: Heime <heimeborgia@protonmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org>
Subject: Re: Printing list to buffer
Date: Sat, 22 Oct 2022 09:48:37 +0300 [thread overview]
Message-ID: <Y1OSRYSAkr5L5YRv@protected.localdomain> (raw)
In-Reply-To: <hiG-yfkOcpOnB3cQyE4os4Wkv_YWS0FIpEHNGWgtiyphY7m-wzQ3QZowUHUgS1QtAeGnzJQSgtjVZCVYG87ouVwIumhDrtVGitBc88YCGZ0=@protonmail.com>
* 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/
prev parent reply other threads:[~2022-10-22 6:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1OSRYSAkr5L5YRv@protected.localdomain \
--to=bugs@gnu.support \
--cc=heimeborgia@protonmail.com \
--cc=help-gnu-emacs@gnu.org \
/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.
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).