[ESS] Emacs, ESS and Rmarkdown: Is this the way compile is supposed to work?

Kevin Zembower kev|n @end|ng |rom zembower@org
Thu Apr 27 19:32:48 CEST 2023


Hi, Manuel, thanks for your advice and help.

Here's the section of my ~/.emacs.d/init.el file that I think pertains 
to R and Rmarkdown:
===========================================================
;; Next two sections for editing manpages in markdown (duplicates
;; sections below it, regarding RMarkdown in ESS?)
(autoload 'markdown-mode "markdown-mode"
    "Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist
 
'("\\.\\(?:md\\|markdown\\|mkd\\|mdown\\|mkdn\\|mdwn\\)\\'" . 
markdown-mode))

(autoload 'gfm-mode "markdown-mode"
    "Major mode for editing GitHub Flavored Markdown files" t)
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))

;; For working in Markdown (RMarkdown in ESS):
(setq load-path (append load-path (list 
"/usr/share/emacs23/site-lisp/emacs-goodies-el")))
;; (autoload 'markdown-mode "markdown-mode"
;;    "Major mode for editing Markdown files" t)
;; (add-to-list 'auto-mode-alist '("\\.text\\'" . markdown-mode))
;; (add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
;; (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))

;; For working with RMarkdown (polymode):
;; Commented out, to update to poly-R
(setq load-path (append '("~/.emacs.d/polymode/" 
"~/.emacs.d/polymode/modes") load-path))
(require 'poly-R)
;; Below from email at 
https://stat.ethz.ch/pipermail/ess-help/2023-April/013190.html
(define-polymode poly-gfm+r-mode poly-markdown+r-mode
   :lighter " PM-Rmd(gfm)"
   :hostmode 'poly-gfm-hostmode)
(require 'poly-markdown)
(add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
;; associate the new polymode to Rmd files:
(add-to-list 'auto-mode-alist
               '("\\.[rR]md\\'" . poly-gfm+r-mode))
;; uses braces around code block language strings:
;; (setq markdown-code-block-braces t)
=========================================================

I've also attached the whole file to this message.

Thanks, again, for any advice or guidance you can offer.

-Kevin


On 4/24/23 02:45, Manuel Teodoro wrote:
> Hi Kevin,
> 
> I also get sometimes the problem with "cl" library but it is never a 
> critical error that stops me from using Rmd.
> 
> I think the main question is, what is in your emacs configuration file? 
> Probably the problem comes from there.
> 
> For example, for R markdown I have simply the following lines, maybe you 
> can try them and see if the error persist.
> 
> ;; R markdown
> (use-package polymode)
> (use-package poly-R)
> (use-package poly-markdown)
> 
> ;; MARKDOWN
> (add-to-list 'auto-mode-alist '("\\.md" . poly-markdown-mode))
> 
>   ;; R modes
> (add-to-list 'auto-mode-alist '("\\.Snw" . poly-noweb+r-mode))
> (add-to-list 'auto-mode-alist '("\\.Rnw" . poly-noweb+r-mode))
> (add-to-list 'auto-mode-alist '("\\.Rmd" . poly-markdown+r-mode))
>   ;
> 
> I just noticed, this is just in case you have installed use-package. If 
> not, change the first 3 lines for something like
> 
> (require 'polymode)
> (require 'poly-R)
> (require 'poly-markdown)
> 
> Although probably require could also give you trouble, in which case 
> simply remove the 3 lines. The most important are the following lines 
> that are telling emacs to recognize *.Rmd files as markdown.
> 
> If you already have this lines then it would be helpful to see your 

> whole config file because maybe something there is conflicting with 

> markdown or with r markdown.
> 
> Cheers
> Manuel
> 
> On Sun, Apr 23, 2023, 20:11 Kevin Zembower via ESS-help 
> <ess-help using r-project.org <mailto:ess-help using r-project.org>> wrote:
> 
>     Jacob, thanks for your help.
> 
>     Here's the output. I don't understand much of it, but the first mention
>     of anything which seems germane is of "poly-markdown-+r-mode":
>     ===============================================

>     Debugger entered--Lisp error: "Package cl is deprecated"
>         message("%s" "Package cl is deprecated")
>         #f(compiled-function (msg) #<bytecode 0x1fd0c5464193>)("Package
>     cl is
>     deprecated")
>         apply(#f(compiled-function (msg) #<bytecode 0x1fd0c5464193>)
>     "Package
>     cl is deprecated")
>         timer-event-handler([t 0 0 0 nil #f(compiled-function (msg)
>     #<bytecode 0x1fd0c5464193>) ("Package cl is deprecated") idle 0])
>         recursive-edit()
>         debug(error (cl-no-applicable-method clone nil))
>         signal(cl-no-applicable-method (clone nil))
>         cl-no-applicable-method(#s(cl--generic :name clone :dispatches ((0
>     #s(cl--generic-generalizer :name eieio--generic-generalizer
>     :priority 50
>     :tagcode-function cl--generic-struct-tag :specializers-function
>     #f(compiled-function (tag &rest _) #<bytecode 0x155db7511469>))
>     #s(cl--generic-generalizer :name cl--generic-t-generalizer :priority 0
>     :tagcode-function #f(compiled-function (name &rest _) #<bytecode
>     0x1fd0c5305c27>) :specializers-function #f(compiled-function (tag &rest
>     _) #<bytecode 0x1fd0c5305c17>)))) :method-table (#s(cl--generic-method
>     :specializers (eieio-named) :qualifiers nil :uses-cnm t :function
>     #f(compiled-function (obj &rest params) "Clone OBJ, initializing
>     `:parent' to OBJ.\nAll slots are unbound, except those initialized with
>     PARAMS." #<bytecode 0x155db755ec35>)) #s(cl--generic-method
>     :specializers (eieio-instance-inheritor) :qualifiers nil :uses-cnm t
>     :function #f(compiled-function (obj &rest params) "Clone OBJ,
>     initializing `:parent' to OBJ.\nAll slots are unbound, except those
>     initialized with PARAMS." #<bytecode 0x155db74f9af1>))
>     #s(cl--generic-method :specializers (eieio-default-superclass)
>     :qualifiers nil :uses-cnm nil :function #f(compiled-function (obj &rest
>     params) "Make a copy of OBJ, and then apply PARAMS." #<bytecode
>     0x155db7503511>))) :options nil) nil)
>         apply(cl-no-applicable-method #s(cl--generic :name clone
>     :dispatches
>     ((0 #s(cl--generic-generalizer :name eieio--generic-generalizer
>     :priority 50 :tagcode-function cl--generic-struct-tag
>     :specializers-function #f(compiled-function (tag &rest _) #<bytecode
>     0x155db7511469>)) #s(cl--generic-generalizer :name
>     cl--generic-t-generalizer :priority 0 :tagcode-function
>     #f(compiled-function (name &rest _) #<bytecode 0x1fd0c5305c27>)
>     :specializers-function #f(compiled-function (tag &rest _) #<bytecode
>     0x1fd0c5305c17>)))) :method-table (#s(cl--generic-method :specializers
>     (eieio-named) :qualifiers nil :uses-cnm t :function
>     #f(compiled-function
>     (obj &rest params) "Clone OBJ, initializing `:parent' to OBJ.\nAll

>     slots
>     are unbound, except those initialized with PARAMS." #<bytecode
>     0x155db755ec35>)) #s(cl--generic-method :specializers
>     (eieio-instance-inheritor) :qualifiers nil :uses-cnm t :function
>     #f(compiled-function (obj &rest params) "Clone OBJ, initializing
>     `:parent' to OBJ.\nAll slots are unbound, except those initialized with
>     PARAMS." #<bytecode 0x155db74f9af1>)) #s(cl--generic-method
>     :specializers (eieio-default-superclass) :qualifiers nil :uses-cnm nil
>     :function #f(compiled-function (obj &rest params) "Make a copy of OBJ,
>     and then apply PARAMS." #<bytecode 0x155db7503511>))) :options nil) nil)
>         #f(compiled-function (&rest args) #<bytecode 0x155db79c1179>)(nil)
>         apply(#f(compiled-function (&rest args) #<bytecode 0x155db79c1179>)
>     nil nil)
>         clone(nil)
>         (let ((config (clone poly-markdown+r-mode))) (eieio-oset config
>     ':minor-mode 'poly-gfm+r-mode) (pm-initialize config))
>         (if pm/polymode nil (let ((config (clone poly-markdown+r-mode)))
>     (eieio-oset config ':minor-mode 'poly-gfm+r-mode) (pm-initialize
>     config)))
>         (let ((last-message (current-message))) (if pm/polymode nil (let
>     ((config (clone poly-markdown+r-mode))) (eieio-oset config ':minor-mode
>     'poly-gfm+r-mode) (pm-initialize config))) (setq poly-gfm+r-mode t)
>     (run-hooks 'poly-gfm+r-mode-hook) (if (and (called-interactively-p

>     'any)
>     (or (null (current-message)) (not (equal last-message
>     (current-message))))) (progn (message "gfm+r polymode enabled")))
>     (force-mode-line-update))
>         (if poly-gfm+r-mode nil (let ((last-message (current-message))) (if
>     pm/polymode nil (let ((config (clone poly-markdown+r-mode)))
>     (eieio-oset
>     config ':minor-mode 'poly-gfm+r-mode) (pm-initialize config))) (setq
>     poly-gfm+r-mode t) (run-hooks 'poly-gfm+r-mode-hook) (if (and
>     (called-interactively-p 'any) (or (null (current-message)) (not (equal
>     last-message (current-message))))) (progn (message "gfm+r polymode

>     enabled"))) (force-mode-line-update)))
>         poly-gfm+r-mode()
>         set-auto-mode-0(poly-gfm+r-mode nil)
>         set-auto-mode()
>         normal-mode(t)
>         after-find-file(nil t)
>         find-file-noselect-1(#<buffer Prob_17_Page_295.Rmd>
>     "~/Documents/Dan/Math_Stats/Prob_17_Page_295.Rmd" nil nil
>     "~/Documents/Dan/Math_Stats/Prob_17_Page_295.Rmd" (69338481 2067))

> 
>     find-file-noselect("/home/kevin/Documents/Dan/Math_Stats/Prob_17_Page_...")
>         #f(compiled-function (displayable-buffers dir line column name)
>     #<bytecode 0x1fd0c5450cb9>)((nil) "~/Documents/Dan/Math_Stats/" (0) (0)
>     "Prob_17_Page_295.Rmd")
>         command-line-1(("Prob_17_Page_295.Rmd"))
>         command-line()
>         normal-top-level()
>     ========================================
> 
>     Thanks for any ongoing advice.
> 
>     -Kevin
> 
>     On 4/23/23 13:34, Jacob Kasper wrote:
>      > For package cl is depreciated you can read this thread. I don't

>     think
>      > this is causing any issues with markdown.
>      >
>     https://www.reddit.com/r/emacs/comments/zslyem/package_cl_is_deprecated_debugging/ <https://www.reddit.com/r/emacs/comments/zslyem/package_cl_is_deprecated_debugging/> <https://www.reddit.com/r/emacs/comments/zslyem/package_cl_is_deprecated_debugging/ <https://www.reddit.com/r/emacs/comments/zslyem/package_cl_is_deprecated_debugging/>>
>      >
>      > On Sun, Apr 23, 2023, 17:16 Kevin Zembower via ESS-help
>      > <ess-help using r-project.org <mailto:ess-help using r-project.org>
>     <mailto:ess-help using r-project.org <mailto:ess-help using r-project.org>>> wrote:
>      >
>      >     Tyler, thanks again for your help.
>      >
>      >     I'm sorry to burden you with my problems, but I'm stuck again.
>      >
>      >     I think I have everything installed and up to date. Here's an
>     excerpt
>      >     from M-x package-list-packages:
>      >         markdown-mode      20220212.728  installed             Major
>      >     mode for
>      >     Markdown-formatted text
>      >         poly-R             20230416.1454 installed           
>       Various
>      >     polymodes for R language
>      >         poly-markdown      20230202.1210 installed           
>       Polymode for
>      >     markdown-mode
>      >         poly-noweb         20200316.1315 installed           
>       Polymode
>      >     for noweb
>      >         polymode           20230317.1218 installed           
>       Extensible
>      >     framework for multiple major modes
>      >
>      >     With the exception of poly-noweb, they're all 2023 packages.
>      >
>      >     Yet, when I open an *.Rmd file, I get this in the Messages
>     buffer:
>      >
>      >     File mode specification error: (error Autoloading file
>      >     /home/kevin/.emacs.d/polymode/modes/poly-R.el failed to
>     define function
>      >     poly-gfm+r-mode)
>      >     Package cl is deprecated
>      >
>      >     I then added your alternative define-polymode section, and
>     the error
>      >     about poly-gfm+r-mode went away, but I still have this
>     message in the
>      >     Messages buffer when I start Emacs with an *.Rmd file:
>      >
>      >     File mode specification error: (cl-no-applicable-method clone
>     nil)
>      >     Package cl is deprecated
>      >
>      >     I can't find a reference to a 'cl' package in my init.el. In
>     addition,
>      >     the *.Rmd file is in Fundamental mode, and not ESS or poly-R
>     mode.
>      >
>      >     When I try to manually invoke the poly mode, with 'M-x
>      >     poly-gfm+r-mode',
>      >     I get the message:
>      >
>      >     cl-no-applicable-method: No applicable method: clone, nil
>      >
>      >     Any ideas what's going on with my system? I'm so worried I'm just
>      >     making
>      >     a hash of things with these changes.
>      >
>      >     Thanks for any advice or guidance.
>      >
>      >     -Kevin
>      >
>      >     On 4/22/23 06:00, ess-help-request using r-project.org
>     <mailto:ess-help-request using r-project.org>
>      >     <mailto:ess-help-request using r-project.org
>     <mailto:ess-help-request using r-project.org>> wrote:
>      >      > ------------------------------
>      >      >
>      >      > Message: 2
>      >      > Date: Fri, 21 Apr 2023 11:09:43 -0400
>      >      > From: "Tyler Smith"<tyler using plantarum.ca
>     <mailto:tyler using plantarum.ca> <mailto:tyler using plantarum.ca
>     <mailto:tyler using plantarum.ca>>>
>      >      > To: ESS-help<ess-help using r-project.org
>     <mailto:ess-help using r-project.org> <mailto:ess-help using r-project.org
>     <mailto:ess-help using r-project.org>>>
>      >      > Subject: Re: [ESS] Emacs, ESS and Rmarkdown: Is this the
>     way compile
>      >      >       is supposed to work?
>      >      >
>     Message-ID:<a2b88f26-7760-41c2-8e9d-e4ea5de4bf21 using app.fastmail.com
>     <mailto:a2b88f26-7760-41c2-8e9d-e4ea5de4bf21 using app.fastmail.com>
>      >     <mailto:a2b88f26-7760-41c2-8e9d-e4ea5de4bf21 using app.fastmail.com
>     <mailto:a2b88f26-7760-41c2-8e9d-e4ea5de4bf21 using app.fastmail.com>>>
>      >      > Content-Type: text/plain; charset="us-ascii"
>      >      >
>      >      > Hi Kevin,
>      >      >
>      >      > If you have an older version of `poly-R`, the function
>      >     `poly-gfm+r-mode` might not be present. This was added to
>     `poly-R`
>      >     dev in July 2021, I'm not sure exactly when it would have
>     been added
>      >     to the released version.
>      >      >
>      >      > If that's the case, updating to the current version of
>     `poly-R`
>      >     should fix the problem.
>      >      >
>      >      > Alternatively, you need the following code evaluated*after*
>      >     `(require 'poly-R)` and*before*  `(add-to-list ...)`:
>      >      >
>      >      > ```
>      >      > (define-polymode poly-gfm+r-mode poly-markdown+r-mode
>      >      >    :lighter " PM-Rmd(gfm)"
>      >      >    :hostmode 'poly-gfm-hostmode)
>      >      > ```
>      >      >
>      >      > But that really shouldn't be necessary.
>      >      >
>      >      > Best,
>      >      >
>      >      > Tyler
>      >      > -- plantarum.ca <http://plantarum.ca> <http://plantarum.ca
>     <http://plantarum.ca>>
>      >
>      >
>      >     ______________________________________________
>      > ESS-help using r-project.org <mailto:ESS-help using r-project.org>
>     <mailto:ESS-help using r-project.org <mailto:ESS-help using r-project.org>>
>     mailing list
>      > https://stat.ethz.ch/mailman/listinfo/ess-help
>     <https://stat.ethz.ch/mailman/listinfo/ess-help>
>      >     <https://stat.ethz.ch/mailman/listinfo/ess-help
>     <https://stat.ethz.ch/mailman/listinfo/ess-help>>
>      >
> 
> 
>     ______________________________________________
>     ESS-help using r-project.org <mailto:ESS-help using r-project.org> mailing list
>     https://stat.ethz.ch/mailman/listinfo/ess-help
>     <https://stat.ethz.ch/mailman/listinfo/ess-help>
> 


More information about the ESS-help mailing list