Re: [ESS] Following up, success! [was RE: [R-win] Difficulty installing R packages under Windows 11 / Cygwin]

2024-01-03 Thread Robert Lerche via ESS-help
Yes and thanks for responding.  That is I think exactly what's needed and I 
have taken a shot at implementing it.  [I'm glad my previous attached patch got 
filtered, I was a bit careless.]  Here's a summary of what I've done:

ess-custom.el: extract prefix using cygpath, set to nil if error (i.e., no 
cygpath command indicates not in Cygwin)
ess-inf.el: add prefix to initial setcwd()
ess-r-mode.el: add prefix to path sent to R for initialization (I know my 
change to ess-r--load-ESSR-local is right, I'm not sure about 
ess-r--fetch-ESSR-remote)

---
diff --git a/lisp/ess-custom.el b/lisp/ess-custom.el
index f631e04d..e4db36c0 100644
--- a/lisp/ess-custom.el
+++ b/lisp/ess-custom.el
@@ -2489,6 +2489,11 @@ Used to store the values for passing on to newly created 
buffers.")
 (defvar ess-STERM nil
   "Placeholder for dialect-specific STERM.")
 
+(defvar ess-cygwin-prefix
+  (condition-case nil (nth 0 (process-lines "cygpath"  "-m" "/"))
+(error nil))
+  "For Windows compatibility, prefix paths passed to R with this")
+
 (make-obsolete-variable 'ess-S-loop-timeout "It is ignored." "ESS 18.10")
 (make-obsolete-variable 'ess-mode-load-hook "It is ignored." "ESS 18.10")
 (make-obsolete-variable 'ess-speedbar-use-p "It is ignored." "ESS 18.10")
diff --git a/lisp/ess-inf.el b/lisp/ess-inf.el
index 9ca3f455..9b611934 100644
--- a/lisp/ess-inf.el
+++ b/lisp/ess-inf.el
@@ -3046,7 +3046,7 @@ NO-ERROR prevents errors when this has not been 
implemented for
  path))
  (lpath (if remote
 (with-parsed-tramp-file-name path v v-localname)
-  path)))
+  (concat ess-cygwin-prefix path
 (ess-eval-linewise (format ess-setwd-command lpath))
 (ess-set-process-variable 'default-directory
   (file-name-as-directory path)))
diff --git a/lisp/ess-r-mode.el b/lisp/ess-r-mode.el
index bd902710..7c093763 100644
--- a/lisp/ess-r-mode.el
+++ b/lisp/ess-r-mode.el
@@ -1572,7 +1572,7 @@ Source the etc/ESSR/.load.R file into the R process. The
 .ess.ESSR.load function sources all of the contents of the
 etc/ESSR/R directory into the ESSR environment and attaches the
 environment to the search path."
-  (let* ((src-dir (expand-file-name "ESSR/R" ess-etc-directory))
+  (let* ((src-dir (concat ess-cygwin-prefix (expand-file-name "ESSR/R" 
ess-etc-directory)))
  (buf (ess-command (ess-r--load-ESSR-command src-dir
 (with-current-buffer buf
   (let ((msg (buffer-string)))
@@ -1614,7 +1614,7 @@ environment from GitHub and attaches it to the search 
path. If
 the file already exists on disk from a previous download then the
 download step is omitted. This function returns t if the ESSR
 load is successful, and nil otherwise."
-  (let ((loader (ess-file-content (expand-file-name "ESSR/LOADREMOTE" 
ess-etc-directory)))
+  (let ((loader (ess-file-content (concat ess-cygwin-prefix (expand-file-name 
"ESSR/LOADREMOTE" ess-etc-directory
 (essr (or essr-version
   ;; FIXME: Hack: on MELPA essr-version is not set
   (lm-with-file (expand-file-name "ess.el" ess-lisp-directory)

From: Sparapani, Rodney  
Sent: Wednesday, January 3, 2024 11:45 AM
To: Robert Lerche ; Dirk Eddelbuettel 
; Tomas Kalibera 
Cc: ess-help (ess-help@r-project.org) 
Subject: Re: Following up, success! [was RE: [ESS] [R-win] Difficulty 
installing R packages under Windows 11 / Cygwin]

[EXTERNAL MESSAGE] Be mindful when clicking links or attachments
Hi Robert:

Looking this over.  The issue appears to be that you need a prefix.
It has been a long time since I used Cygwin.  But I assume the
prefix is something like "c:" or "/cygwin/c".  In other words, 
the root is NOT "/"; rather something like $PREFIX/  Is that the issue?
I'm trying to think of a way that we could easily adapt to this
without hacking all over the places.  Possibly, we could support
PREFIX kind of like the way configure works.  Thanks

-- 
Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
Vice President, Wisconsin Chapter of the American Statistical Association
Institute for Health and Equity, Division of Biostatistics
Medical College of Wisconsin, Milwaukee Campus

From: Robert Lerche 
Date: Tuesday, January 2, 2024 at 7:00 PM
To: Dirk Eddelbuettel , Tomas Kalibera 

Cc: Sparapani, Rodney , ess-help 
(mailto:ess-help@r-project.org) 
Subject: Following up, success! [was RE: [ESS] [R-win] Difficulty installing R 
packages under Windows 11 / Cygwin]
ATTENTION: This email originated from a sender outside of MCW. Use caution when 
clicking on links or opening attachments.


It turns out it was fairly easy to make ESS work in Cygwin Emacs with R built 
for Windows.  The issue was of course path names.  I attach a 

Re: [ESS] Following up, success! [was RE: [R-win] Difficulty installing R packages under Windows 11 / Cygwin]

2024-01-03 Thread Sparapani, Rodney via ESS-help
Hi Robert:

Looking this over.  The issue appears to be that you need a prefix.
It has been a long time since I used Cygwin.  But I assume the
prefix is something like �c:� or �/cygwin/c�.  In other words,
the root is NOT �/�; rather something like $PREFIX/  Is that the issue?
I�m trying to think of a way that we could easily adapt to this
without hacking all over the places.  Possibly, we could support
PREFIX kind of like the way configure works.  Thanks

--
Rodney Sparapani, Associate Professor of Biostatistics, He/Him/His
Vice President, Wisconsin Chapter of the American Statistical Association
Institute for Health and Equity, Division of Biostatistics
Medical College of Wisconsin, Milwaukee Campus

From: Robert Lerche 
Date: Tuesday, January 2, 2024 at 7:00 PM
To: Dirk Eddelbuettel , Tomas Kalibera 

Cc: Sparapani, Rodney , ess-help (ess-help@r-project.org) 

Subject: Following up, success! [was RE: [ESS] [R-win] Difficulty installing R 
packages under Windows 11 / Cygwin]
ATTENTION: This email originated from a sender outside of MCW. Use caution when 
clicking on links or opening attachments.


It turns out it was fairly easy to make ESS work in Cygwin Emacs with R built 
for Windows.  The issue was of course path names.  I attach a patch that works 
for me.

Let me explain that I am using a company-provided and managed laptop and I have 
no choice but to run Windows. I am familiar with a number of Unix/Linux -like 
environments for Windows (Cygwin, MSYS, WSL). I have tried them all over a 
period of years. I use R primarily as a means for presenting data.  It is not 
the main thrust of my work.  Having spent considerable time making this laptop 
a comfortable working environment I am loathe to switch.

[[alternative HTML version deleted]]

__
ESS-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/ess-help


Re: [R] Help request: Parsing docx files for key words and appending to a spreadsheet

2024-01-03 Thread Dr Eberhard Lisse
If you do something like this

for i in  $(pandoc --list-output-formats);
do pandoc -f docx -t $i -o test.$i Now\ they\ want\ us\ to\ 
charge\
our\ electric\ cars\ from\ litter\ bins.docx;
done

you get approximately 65 formats, from which you can pick one which you can
write a little parser for. The dokuwiki one for example uses long lines
which
makes parsing easier.

el


On 2023-12-30 13:57 , Andy wrote:
> Good idea, El - thanks.
>
> The link is
> https://docs.google.com/document/d/1QwuaWZk6tYlWQXJ3WLczxC8Cda6zVERk/edit?usp=sharing=103065135255080058813=true=true
>
>  This is helpful.
>
> From the article, which is typical of Lexis+ output, I want to
> extract the following fields and append to a Calc/ Excel spreadsheet.
> Given the volume of articles I have to work through, if this can be
> iterative and semi-automatic, that would be a god send and I might be
> able to do some actual research on the articles before I reach my
> pensionable age. :-)
>
> Title Newspaper Date Section and page number Length Byline Subject
> (only if the threshold of coverage for a specific subject is
>> =50% is reached (e.g. Greenwashing (51%)) - if not, enter 'nil' and
>>
> move onto the next article in the folder
>
> This is the ambition. I am clearly a long way short of that though.
>
> Many thanks. Andy

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.