[ESS] ESS 5.14 and ?? shortcut syntax (and kludge in input-sender)

Vitalie Spinu spinuvit.list at gmail.com
Thu Aug 11 11:40:31 CEST 2011


>
> No documentation for '?test' in specified packages and libraries:
> you could try '???test'
>

This problem is annotated in ess-help.el, so developers are  aware of
it. It was not a priority probably.
It's indeed easy to address. I attach the patch which solves this issue.

Since it's all about modification of 'inferior-R-input-sended' I would
like to point out another kludge in this command.

If you type

Sys.sleep(5)

at R prompt emacs will froze for 5 second. It happens with any command
which takes time to execute.
I am sure this has been reported before.

The problem stems from the fact that comint is waiting to delete the
double input (comint-process-echoes is set to 't' in *R* buffers, see
the doc).

What happens is:  'inferior-R-input-sender' calls 'ess-eval-linewise'
which inserts the user input and double it (since it's already in the
buffer). Then comint is waiting to delete
the doubled input.

The kludge is easy to correct, just call 'process-send-string' instead
of 'ess-eval-linewise'.  This will free emacs immediately.

I incorporated these changes in ess-tracebug
(http://code.google.com/p/ess-tracebug/). You can toggle it on and off
with M-x ess-tracebug and see the difference.

The patch bellow also corrects this kludge.

Best,
Vitalie.


Index: ess-inf.el
===================================================================
--- ess-inf.el	(revision 4533)
+++ ess-inf.el	(working copy)
@@ -1619,7 +1619,8 @@
   (if (or (string= ess-language "S"))
       (cond
        ((string= ess-dialect "R")
-	(setq comint-input-sender 'inferior-R-input-sender))
+	(setq comint-input-sender 'inferior-R-input-sender)
+        (setq comint-process-echoes nil))
        ( (member ess-dialect '("S3" "S4" "S+3" "S+4" "S+5" "S+6" "S"))
 	(setq comint-input-sender 'inferior-ess-input-sender))))

@@ -1744,7 +1745,7 @@
 ;; FIXME: Note that  '??' nicely works in *R*, but
 ;;	  'type ? topic' doesn't use ess-help {but display in *R*}
 (defconst inferior-R-1-input-help (format "^ *help *(%s)" ess-help-arg-regexp))
-(defconst inferior-R-2-input-help (format "^ *\\? *%s" ess-help-arg-regexp))
+(defconst inferior-R-2-input-help "^ *\\(\\?\\{1,2\\}\\)
*['\"]?\\([^,=)'\"]*\\)['\"]?")
 (defconst inferior-R-page	  (format "^ *page *(%s)" ess-help-arg-regexp))

 (defun inferior-R-input-sender (proc string)
@@ -1756,7 +1757,8 @@
                            (string-match inferior-R-2-input-help string)))
           (page-string	 (string-match inferior-R-page	       string)))
       (if (or help-string page-string)
-          (let* ((string2 (match-string 2 string)))
+          (let ((string1 (match-string 1 string))
+                (string2 (match-string 2 string)))
             ;;(ess-write-to-dribble-buffer (format " new
string='%s'\n" string2))
             (beginning-of-line)
             (if (looking-at inferior-ess-primary-prompt)
@@ -1765,10 +1767,12 @@
                   (insert-before-markers string)) ;; emacs 21.0.105 and older
               (delete-backward-char 1)) ;; emacs 21.0.106 and newer
             (if help-string ; more frequently
-		(progn
-		  (ess-display-help-on-object
-		   (if (string= string2 "") "help" string2))
-		  (ess-eval-linewise "\n"))
+                (let ((inferior-ess-help-command
+                       (if (string= string1 "?")
inferior-ess-help-command "help.search(\"%s\")\n")))
+                  (progn
+                    (ess-display-help-on-object
+                     (if (string= string2 "") "help" string2))
+                    (ess-eval-linewise "\n")))

 	      ;; else  page-string
 	      (let ((str2-buf (concat string2 ".rt")))
@@ -1778,7 +1782,8 @@
 		(switch-to-buffer-other-window str2-buf)
 		(R-transcript-mode))))
         ;; else:	normal command
-        (inferior-ess-input-sender proc string)))))
+        (process-send-string proc (concat string "\n"))
+        ))))



More information about the ESS-help mailing list