#| -*-Scheme-*-
-$Id: lisppaste.scm,v 1.1 2006/11/04 20:25:17 riastradh Exp $
+$Id: lisppaste.scm,v 1.2 2008/10/18 21:20:25 riastradh Exp $
This code is written by Taylor R. Campbell and placed in the Public
Domain.
lisppaste-insert-paste)
(define (lisppaste-create channel nickname title content)
- (message (lisppaste:new-paste channel nickname title content)))
+ (message-or-pop-up (lisppaste:new-paste channel nickname title content)))
(define-command lisppaste-buffer
"Create a new paste of the current buffer."
(list channel nickname title))))
(define (lisppaste-annotate number nickname title content)
- (message (lisppaste:new-paste
- (lisppaste-entry/channel (lisppaste:paste-header number))
- nickname
- title
- content
- number)))
+ (message-or-pop-up
+ (lisppaste:new-paste
+ (lisppaste-entry/channel (lisppaste:paste-header number))
+ nickname
+ title
+ content
+ number)))
(define-command lisppaste-annotate-with-buffer
"Annotate an existing paste with the current buffer."
()
(lambda ()
(call-with-output-to-temporary-buffer " *lisppaste channels*"
- '(SHRINK-WINDOW FLUSH-ON-SPACE)
+ '(READ-ONLY SHRINK-WINDOW FLUSH-ON-SPACE)
(lambda (port)
(write-strings-densely (lisppaste:list-channels) port)))))
(define (lisppaste-list-pastes entries)
(call-with-output-to-temporary-buffer " *lisppastes*"
- '(SHRINK-WINDOW FLUSH-ON-SPACE)
+ '(READ-ONLY SHRINK-WINDOW FLUSH-ON-SPACE)
(lambda (port)
(for-each (lambda (entry)
(show-lisppaste entry port))
;;;; Lisppaste RPC
;;; This could be used outside of Edwin if it made no reference to the
-;;; Edwin variable LISPPASTE-RPC-URI.
+;;; Edwin variable LISPPASTE-RPC-URI or the procedure EDITOR-ERROR.
(define (lisppaste-rpc method-name required-arguments optional-argument)
(let ((result
optional-argument))))
(if (and (string? result)
(string-prefix? "Error" result))
- (error result)
+ (editor-error result)
result)))
(define (lisppaste-request method-name required-arguments optional-argument)
(lisppaste-entry/annotations entry)
(lisppaste-entry/content entry)))
\f
-;;;; Random Utility
+;;;; Random Utilities
(define (prompt-for-lazy-string-table-name prompt
default-string
(lambda (index) index default))
default))))
options))
+
+(define (message-or-pop-up string)
+ (if (and (not (string-find-next-char string #\newline))
+ (let ((tab-width (ref-variable tab-width #f))
+ (char-image-strings (ref-variable char-image-strings #f)))
+ (< (string-columns string 0 tab-width char-image-strings)
+ (window-x-size (typein-window)))))
+ (message string)
+ (string->temporary-buffer string
+ " *lisppaste-error*"
+ '(READ-ONLY SHRINK-WINDOW FLUSH-ON-SPACE))))