52
52
(autoload 'ess-eval-line "ess-inf" "[autoload]" t)
53
53
(autoload 'ess-eval-line-and-go "ess-inf" "[autoload]" t)
54
54
(autoload 'ess-eval-line-and-step "ess-inf" "[autoload]" t)
55
(autoload 'ess-with-current-buffer "ess-inf" "[autoload]" t)
56
57
(autoload 'ess-goto-beginning-of-function-or-para "ess-mode" "[autoload]" t)
57
58
(autoload 'ess-goto-end-of-function-or-para "ess-mode" "[autoload]" t)
143
144
(ess-force-buffer-current)
144
145
(when current-prefix-arg ;update cache if prefix
145
(with-current-buffer (process-buffer (ess-get-process ess-current-process-name))
146
(ess-process-put 'sp-for-help-changed? t)))
146
(ess-process-put 'sp-for-help-changed? t))
147
147
(if (ess-ddeclient-p)
148
148
(list (read-string "Help on: "))
149
149
(list (ess-find-help-file "Help on")))))
285
285
((string-match "^R" ess-dialect)
286
(setq com-package-for-object "sub('package:', '', utils::find('%s'))\n"
286
;; carefully using syntax to be parsed in old R versions (no '::', '_'):
287
(setq com-package-for-object "sub('package:', '', .ess.findFUN('%s'))\n"
287
288
com-packages ".packages(all.available=TRUE)\n"
288
com-package-index "help(package='%s', help_type='text')\n"
289
com-package-index ".ess.help(package='%s', help.type='text')\n"
289
290
reg-keyword "^\\([-a-zA-Z0-9._@$]+\\)[^:\n]*$"
290
291
reg-start "^Index:"))
291
292
((string-match "julia" ess-dialect)
547
548
(ess--find-displayed-help-window)))))
550
(select-window help-win)
551
(switch-to-buffer buff nil 'force))
551
(select-window help-win 'norecord)
552
(set-window-buffer help-win buff)
553
;; (switch-to-buffer buff nil 'force) <- 3rd argument appeared in emacs 24
552
555
(if ess-help-pop-to-buffer
553
556
(pop-to-buffer buff)
554
557
(ess-display-temp-buffer buff)))))
674
677
;; One reason for the following menu is to <TEACH> the user about key strokes
675
678
(defvar ess-help-mode-menu
677
["Search Forward" isearch-forward t]
678
["Next Section" ess-skip-to-next-section t]
679
["Previous Section" ess-skip-to-previous-section t]
680
["Help on Section Skipping" ess-describe-sec-map t]
681
["Beginning of Buffer" beginning-of-buffer t]
682
["End of Buffer" end-of-buffer t]
684
["Help on ..." ess-display-help-on-object t]
685
["Apropos of ..." ess-display-help-apropos t]
686
["Index of ..." ess-display-package-index t]
687
["Vignettes" ess-display-vignettes t]
688
["Open in Browser" ess-display-help-in-browser t]
690
["Eval Line" ess-eval-line-and-step t]
691
["Eval Paragraph & step" ess-eval-paragraph-and-step t]
692
["Eval Region & Go" ess-eval-region-and-go t]
693
["Switch to ESS Process" ess-switch-to-ESS t]
694
["Switch to End of ESS Proc." ess-switch-to-end-of-ESS t]
695
["Switch _the_ Process" ess-switch-process t]
697
["Kill Buffer" kill-this-buffer t]
698
["Kill Buffer & Go" ess-kill-buffer-and-go t]
700
["Handy comomands" ess-handy-commands t]
701
["Describe ESS-help Mode" ess-describe-help-mode t]
680
["Search Forward" isearch-forward t]
681
["Next Section" ess-skip-to-next-section t]
682
["Previous Section" ess-skip-to-previous-section t]
683
["Help on Section Skipping" ess-describe-sec-map t]
684
["Beginning of Buffer" beginning-of-buffer t]
685
["End of Buffer" end-of-buffer t]
687
["Help on ..." ess-display-help-on-object t]
688
["Apropos of ..." ess-display-help-apropos t]
689
["Index of ..." ess-display-package-index t]
690
["Vignettes" ess-display-vignettes t]
691
["Open in Browser" ess-display-help-in-browser t]
693
["Eval Line" ess-eval-line-and-step t]
694
["Eval Paragraph & step" ess-eval-paragraph-and-step t]
695
["Eval Region & Go" ess-eval-region-and-go t]
696
["Switch to ESS Process" ess-switch-to-ESS t]
697
["Switch to End of ESS Proc." ess-switch-to-end-of-ESS t]
698
["Switch _the_ Process" ess-switch-process t]
700
["Kill Buffer" kill-this-buffer t]
701
["Kill Buffer & Go" ess-kill-buffer-and-go t]
703
["Handy commands" ess-handy-commands t]
704
["Describe ESS-help Mode" ess-describe-help-mode t]
703
706
"Menu used in ess-help mode.")
760
763
ess-help-sec-keys-alist))))
761
764
(if (not the-sec) (error "Invalid section key: %c"
762
765
last-command-event)
763
(if (re-search-forward (concat "^" the-sec) nil t) nil
766
(if (re-search-forward (concat "^" the-sec) nil t)
764
768
(message "No %s section in this help. Sorry." the-sec)
765
769
(goto-char old-point))))))
883
887
(defun ess-get-help-aliases-list ()
884
888
"Return a list of aliases which have help available."
885
(let ((readrds (if (ess-current-R-at-least "2.13.0")
889
(mapcar (lambda (str)
890
(let ((a-file (concat str "/help/aliases.rds")))
891
(and (file-exists-p a-file)
892
(ess-get-words-from-vector
893
(format "names(%s(\"%s\"))\n" readrds a-file)))))
894
(ess-get-words-from-vector "searchpaths()\n")))))
889
(ess-write-to-dribble-buffer "Processing RDS files ...\n")
890
(ess-get-words-from-vector ".ess.getHelpAliases()\n"))
896
892
(defun ess-nuke-help-bs ()
897
893
"Remove ASCII underlining and overstriking performed by ^H codes."
950
946
(defun ess-describe-object-at-point ()
951
947
"Get info for object at point, and display it in an electric buffer or tooltip.
952
This is an electric command (see `ess--execute-electric-command').
954
948
If region is active use it instead of the object at point.
956
After invocation of this command, all standard emacs commands,
950
This is an electric command (`ess--execute-electric-command'),
951
which means that you can use the last key to cycle through the
952
action set (in this case `C-e').
954
After invocation of this command all standard emacs commands,
957
955
except those containing 'window' in their names, remove the
958
956
electric *ess-describe* buffer. Use `other-window' to switch to
959
957
*ess-describe* window.
962
960
the description in a tooltip.
964
962
See also `ess-R-describe-object-at-point-commands' (and similar
965
option for other dialects).
963
option for other dialects)."
968
965
(if (not ess-describe-object-at-point-commands)
969
966
(message "Not implemented for dialect %s" ess-dialect)
978
975
;; todo: put digits into the map
979
976
(let* ((inhibit-quit t) ;; C-g removes the buffer
980
977
(buf (ess--execute-electric-command
981
map (format "Press %s to cycle" (single-key-description last-command-event))
978
map (format "Press %s to cycle"
979
(single-key-description last-command-event))
982
980
nil nil objname))
983
981
;; read full command
984
982
(keys (read-key-sequence-vector ""))
985
983
(command (and keys (key-binding keys))))
986
984
(when (and (commandp command)
988
(not (string-match "window" (symbol-name command))))
986
(or (not (symbolp command)) ;; kill on lambdas
987
(not (string-match "window" (symbol-name command)))))
989
988
(kill-buffer buf)) ;; bury does not work here :( (emacs bug?)
990
989
(setq unread-command-events
991
990
(append keys unread-command-events)))
1001
1000
;; can take some time for the command to execute
1002
1001
(display-buffer buf))
1004
(ess-command (concat com "\n") buf)
1003
(ess-command (concat com "\n") buf) ;; erases buf
1005
1004
(with-current-buffer buf
1006
1005
(goto-char (point-min))
1007
1006
(insert (propertize (format "%s:\n\n" com) 'face 'font-lock-string-face))
1008
1007
(forward-line -1)
1009
1008
(setq pos (point))
1010
(setq buffer-read-only t))
1009
;; set the keys that we are used to in help mode
1011
(local-set-key "k" 'kill-this-buffer))
1011
1012
(if (eq ess-describe-at-point-method 'tooltip)
1012
1013
(ess-tooltip-show-at-point
1013
1014
(with-current-buffer buf (buffer-string)) 0 30)