You can subscribe to this list here.
2016 |
Jan
|
Feb
|
Mar
(12) |
Apr
(19) |
May
(60) |
Jun
(77) |
Jul
(23) |
Aug
(8) |
Sep
(28) |
Oct
(16) |
Nov
(95) |
Dec
(56) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2017 |
Jan
(127) |
Feb
(169) |
Mar
(59) |
Apr
(132) |
May
(27) |
Jun
|
Jul
(7) |
Aug
(1) |
Sep
(15) |
Oct
(12) |
Nov
(15) |
Dec
(17) |
2018 |
Jan
|
Feb
(2) |
Mar
(25) |
Apr
(19) |
May
(28) |
Jun
(75) |
Jul
(48) |
Aug
|
Sep
(31) |
Oct
(26) |
Nov
(51) |
Dec
(82) |
2019 |
Jan
(46) |
Feb
(7) |
Mar
(8) |
Apr
|
May
(9) |
Jun
(8) |
Jul
(21) |
Aug
(30) |
Sep
(9) |
Oct
(16) |
Nov
(14) |
Dec
(23) |
2020 |
Jan
|
Feb
(6) |
Mar
|
Apr
(7) |
May
(47) |
Jun
(12) |
Jul
(7) |
Aug
(5) |
Sep
(4) |
Oct
(24) |
Nov
(15) |
Dec
(14) |
2021 |
Jan
(6) |
Feb
(5) |
Mar
(20) |
Apr
(6) |
May
(46) |
Jun
(17) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2022 |
Jan
|
Feb
(1) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
2023 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(8) |
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2025 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Laurent L. <Lau...@un...> - 2021-05-26 15:41:26
|
Hi Bernard, > On 26 May 2021, at 16:44, Bernard Desgraupes <bde...@or...> wrote: > > Hi Laurent, > > thank you for reporting this. I don’t know what’s going on there. > > Is it possible that the port used by the AlphaServer (51954) is already in use on your machine ? Any idea how I could check that? > > To help me debug, could you execute the following two commands from the Tcl shell (cmd-Y) once Alpha is running after this activation error: > > alphaServer::port > alphaServer::isRunning > > > Here is for instance what I get on my machine: > Welcome to Alpha's AlphaTcl shell. > «» alphaServer::port > 51954 I get 59218. The default value of 51954 is detected in several files when I run from a terminal « grep -r 51954 /Applications/Alpha.app ». But for some reason, it apparently looks interpreted as busy and another port number is (randomly) chosen. > «» alphaServer::isRunning > 1 I get 1 > «» set alphaServer::serverAddress > 127.0.0.1 I get 127.0.0.1 To further document the behaviour of the error message window: the « OK » button is initially displayed in blue and I need to click it, changing its aspect to un-coloured transparent, before I can use Alpha. The error message window does not disappear however: it remains with the un-coloured « OK » button. And I « need to search » the new windows that I open in Alpha: command-N results in an Alpha status line message indicating « untitled 'command symbol’1, but the new window is nowhere to be seen first. A sure way to make it appear is for instance to start a search by command-F. Thank you for your reactivity! Laurent > > Bernard > > >> Le 26 mai 2021 à 15:04, Laurent Lamalle <Lau...@un... <mailto:Lau...@un...>> a écrit : >> >> Hello, >> >> I systematically get an error message when starting Alpha, and this has been observed over quite a few latest versions: >> >> Package activation error >> >> The package ‘alphaServer’ will be deactivated if >> possible. See the log file ‘…/Library/Logs/AlphaTcl/ActivationError’. >> >> The window presenting this message displays an « OK » button, but clicking the latter has no effect. >> The window remains open but does not prevent using Alpha. >> >> The mentioned log file indicates: >> >> ---------------------------------------------------------------------- >> Wed May 26 14:38:48 CEST 2021 >> couldn't open socket: nodename nor servname provided, or not known >> while executing >> "socket localhost $serverPort" >> (procedure "::alphaServer::start" line 32) >> invoked from within >> "::alphaServer::start" >> ("uplevel" body line 3) >> invoked from within >> "uplevel #0 { >> # Activation script. >> ::alphaServer::start >> }" >> >> Currently, the earliest occurrence of this error snippet in my log file dates back August 2020, but it is possible I thrashed the file at that time to try understanding what happened, and the problem is likely more ancient. >> >> I did not notice this problem when switching to early AlphaCocoa versions, as far as I remember, and have no idea what could have triggered this behaviour. >> >> I am using macOS HighSierra 10.13.6. >> I just updated to the latest Alpha version. >> >> Any idea? >> >> Thank you in advance for your help. >> >> Best regards, >> >> Laurent Lamalle >> >> >> -- >> Laurent LAMALLE >> Ingénieur de Recherche INSERM >> >> Inserm US 17 >> CNRS UMS 3552 >> Université Grenoble Alpes & CHU Grenoble Alpes UMS IRMaGe >> >> RMN biomédicale et Neurosciences, SFR de l'Université Grenoble Alpes >> >> Unité IRM 3T - Recherche >> CHU de Grenoble >> CS 10217 >> 38043 Grenoble Cedex 9 >> France >> >> Tel : +33 (0)4 76 76 93 07 >> Fax: +33 (0)4 76 76 93 05 >> mailto: Lau...@un... <mailto:Lau...@un...> >> mailto: Lau...@in... <mailto:Lau...@in...> >> https://irmage.univ-grenoble-alpes.fr <https://irmage.univ-grenoble-alpes.fr/> >> _______________________________________________ >> AlphaCocoa-devel mailing list >> Alp...@li... <mailto:Alp...@li...> >> https://lists.sourceforge.net/lists/listinfo/alphacocoa-devel > |
From: Bernard D. <bde...@or...> - 2021-05-26 14:44:30
|
Hi Laurent, thank you for reporting this. I don’t know what’s going on there. Is it possible that the port used by the AlphaServer (51954) is already in use on your machine ? To help me debug, could you execute the following two commands from the Tcl shell (cmd-Y) once Alpha is running after this activation error: alphaServer::port alphaServer::isRunning Here is for instance what I get on my machine: Welcome to Alpha's AlphaTcl shell. «» alphaServer::port 51954 «» alphaServer::isRunning 1 «» set alphaServer::serverAddress 127.0.0.1 Bernard > Le 26 mai 2021 à 15:04, Laurent Lamalle <Lau...@un...> a écrit : > > Hello, > > I systematically get an error message when starting Alpha, and this has been observed over quite a few latest versions: > > Package activation error > > The package ‘alphaServer’ will be deactivated if > possible. See the log file ‘…/Library/Logs/AlphaTcl/ActivationError’. > > The window presenting this message displays an « OK » button, but clicking the latter has no effect. > The window remains open but does not prevent using Alpha. > > The mentioned log file indicates: > > ---------------------------------------------------------------------- > Wed May 26 14:38:48 CEST 2021 > couldn't open socket: nodename nor servname provided, or not known > while executing > "socket localhost $serverPort" > (procedure "::alphaServer::start" line 32) > invoked from within > "::alphaServer::start" > ("uplevel" body line 3) > invoked from within > "uplevel #0 { > # Activation script. > ::alphaServer::start > }" > > Currently, the earliest occurrence of this error snippet in my log file dates back August 2020, but it is possible I thrashed the file at that time to try understanding what happened, and the problem is likely more ancient. > > I did not notice this problem when switching to early AlphaCocoa versions, as far as I remember, and have no idea what could have triggered this behaviour. > > I am using macOS HighSierra 10.13.6. > I just updated to the latest Alpha version. > > Any idea? > > Thank you in advance for your help. > > Best regards, > > Laurent Lamalle > > > -- > Laurent LAMALLE > Ingénieur de Recherche INSERM > > Inserm US 17 > CNRS UMS 3552 > Université Grenoble Alpes & CHU Grenoble Alpes UMS IRMaGe > > RMN biomédicale et Neurosciences, SFR de l'Université Grenoble Alpes > > Unité IRM 3T - Recherche > CHU de Grenoble > CS 10217 > 38043 Grenoble Cedex 9 > France > > Tel : +33 (0)4 76 76 93 07 > Fax: +33 (0)4 76 76 93 05 > mailto: Lau...@un... <mailto:Lau...@un...> > mailto: Lau...@in... <mailto:Lau...@in...> > https://irmage.univ-grenoble-alpes.fr <https://irmage.univ-grenoble-alpes.fr/> > _______________________________________________ > AlphaCocoa-devel mailing list > Alp...@li... > https://lists.sourceforge.net/lists/listinfo/alphacocoa-devel |
From: Laurent L. <Lau...@un...> - 2021-05-26 13:21:25
|
Hello, I systematically get an error message when starting Alpha, and this has been observed over quite a few latest versions: Package activation error The package ‘alphaServer’ will be deactivated if possible. See the log file ‘…/Library/Logs/AlphaTcl/ActivationError’. The window presenting this message displays an « OK » button, but clicking the latter has no effect. The window remains open but does not prevent using Alpha. The mentioned log file indicates: ---------------------------------------------------------------------- Wed May 26 14:38:48 CEST 2021 couldn't open socket: nodename nor servname provided, or not known while executing "socket localhost $serverPort" (procedure "::alphaServer::start" line 32) invoked from within "::alphaServer::start" ("uplevel" body line 3) invoked from within "uplevel #0 { # Activation script. ::alphaServer::start }" Currently, the earliest occurrence of this error snippet in my log file dates back August 2020, but it is possible I thrashed the file at that time to try understanding what happened, and the problem is likely more ancient. I did not notice this problem when switching to early AlphaCocoa versions, as far as I remember, and have no idea what could have triggered this behaviour. I am using macOS HighSierra 10.13.6. I just updated to the latest Alpha version. Any idea? Thank you in advance for your help. Best regards, Laurent Lamalle -- Laurent LAMALLE Ingénieur de Recherche INSERM Inserm US 17 CNRS UMS 3552 Université Grenoble Alpes & CHU Grenoble Alpes UMS IRMaGe RMN biomédicale et Neurosciences, SFR de l'Université Grenoble Alpes Unité IRM 3T - Recherche CHU de Grenoble CS 10217 38043 Grenoble Cedex 9 France Tel : +33 (0)4 76 76 93 07 Fax: +33 (0)4 76 76 93 05 mailto: Lau...@un... mailto: Lau...@in... https://irmage.univ-grenoble-alpes.fr <https://irmage.univ-grenoble-alpes.fr/> |
From: <bde...@or...> - 2021-05-21 13:34:23
|
Hi all, I'm pleased to announce the release of a new version of Alpha. This is Alpha 9.2.3 ("Suhail <https://alphacocoa.sourceforge.io/AlphaStar.html>") for Mac OS X 10.11 or greater (El Capitan, Sierra, High Sierra, Mojave, Catalina, Big Sur). All versions of Alpha are named after a star. So, for this new release, meet Suhail <https://alphacocoa.sourceforge.io/AlphaStar.html>, which is λ Velorum, the λ star of the Vela constellation. Beware: the Maverick (10.9) and Yosemite (10.10) versions of OS X are no longer supported. The latest version of Alpha running on these two systems is 9.0.3. See at the end of this message, the main changes contained in this new release. Please, read the release notes which will be displayed the first time you launch Alpha and can be accessed later from the Help ↣ Developer Help menu. Here is the URL to download the disk image: https://sourceforge.net/projects/alphacocoa/files/9.2.3/Alpha_9.2.3.dmg.zip/download <https://sourceforge.net/projects/alphacocoa/files/9.2.3/Alpha_9.2.3.dmg.zip/download> (32.67M) The MD5 checksum is: cc06bc62b3daff7b58332cd78df58f35 The SHA1 checksum is: fb87dc11b42cc8edf55dbe0d73214b32536bceb1 The RMD160 checksum is: 4c8f3f5486589731ba67619b3e0f09e193de938e The SHA256 checksum is: f3445a2ecb23cf1f12811d6003890f091e04334cc92cb4f00140065359c7e91a If you find problems with the application, don't hesitate to post bug reports. They are essential to keep track of the deficiencies. See Alpha's Bug Tracker <https://sourceforge.net/p/alphacocoa/tickets/>. Thank you for using Alpha. Cheers, Bernard <>Changes from previous version The Get Char Codes command now displays its results in a popover. Double-click in the popover or press Return to copy the info to the pasteboard. New option -selected for TextField views. It lets you get or set the range of selected characters in a currently active text field. The following bugs have been fixed (but remain open until the fix is confirmed): Ticket #240: Encoding <https://sourceforge.net/p/alphacocoa/tickets/240/> Ticket #246: Freeze at (26, 70) <https://sourceforge.net/p/alphacocoa/tickets/246/> Ticket #248: Problems with the spellchecker of Alpha 9.2.2 in TeX Mode for french <https://sourceforge.net/p/alphacocoa/tickets/248/> Ticket #249: Freeze when using command+I <https://sourceforge.net/p/alphacocoa/tickets/249/> Ticket #250: RemReminder on ticket #248 : Problems with the spellchecker of Alpha 9.2.2 in TeX Mode for french <https://sourceforge.net/p/alphacocoa/tickets/250/> Ticket #252: S+/R mode - Process Current File (Cmd^T) fails <https://sourceforge.net/p/alphacocoa/tickets/252/>The following tickets have been closed: Ticket #130: problem with filename in .tab <https://sourceforge.net/p/alphacocoa/tickets/130/> Ticket #242: Diff missing variable error when trying to run on Mac Catalina <https://sourceforge.net/p/alphacocoa/tickets/242/> Ticket #243: Problems Loading Modes: Diff <https://sourceforge.net/p/alphacocoa/tickets/243/> Ticket #244: Marking in sh mode fails completely or is useless <https://sourceforge.net/p/alphacocoa/tickets/244/> Ticket #245: Dynamical Menus under MacOS Big Sur <https://sourceforge.net/p/alphacocoa/tickets/245/> |
From: L. P. <lau...@us...> - 2021-05-21 13:09:59
|
Hi Bernard Thank you very much. Indeed the problem seems to be solved. We are very fortunate to have you so efficient to take care of Alpha Regards Laurent Praly --- ** [tickets:#250] RemReminder on ticket #248 : Problems with the spellchecker of Alpha 9.2.2 in TeX Mode for french** **Status:** fixed **Created:** Sun Apr 11, 2021 09:30 AM UTC by Laurent PRALY **Last Updated:** Thu May 20, 2021 12:51 PM UTC **Owner:** nobody Having received no comment on ticket 248, I am rewriting it here with increasing its priority to major. I have problems with the spellcker of Alpha 9.2.2 in TeX Mode for french. Specifically in a text in french, the job is not done correctly in presence of accents or in comments. Here are the parameters concerning spelling in my Alpha's configuration for the TeX Mode Choose an implementatation for spellcheck: Alpha Alpha Preferences: "TeX" Mode > LaTeX Accents Accent Smart Escape: Yes Accents in Comments: No Bind LaTeX Accents: No Accente Syntax: \'{e} & \oe{} Alpha Preferences: "TeX" Mode Features LaTeX Accents: Yes My test file is: \documentclass[a4paper,12pt] % letter \begin{document} Nous \'{e}tudions ici le bouclage dynamique de sortie qui est un sujet extr\^{e}mement extremement vaste. Nous nous li-mi-tons \`{a} l'\'{e}nonc\'{e} d'id\'{e}es directrices et \`{a} une pr\'{e}sentation tr\`{e}s in\'{e}gale des r\'{e}sultats, avec beaucoup de d\'{e}tails pour certains et \`{a} peine une \'{e}bauche pour d'autres. \end{document} After starting Alpha, I created a new file with the above content, change the mode to TeX, typed the above and recorded the file. Then Edit > Spelling > Spelcheck window flagged successively the following words, **letter** Find next **extr** Find next **extremement** Correct **d'id** Find next **tr** Find next For me **letter** should not be flagged because it is in a comment. The other flagged words show that TeX accents, as declared in the configuration, are not understood. Worse, the correction of **extremement** I get is **extr\^{e}mement** which is correct. But if I run the spellchecker on the corrected file, the corrected word is flagged as **extr** I have noticed that the problem does not depend in the encoding. It is the same for UTF-8, OSX and ISO. Is there a problem with my configuration or is it a problem with the spellchecker ? Auxiliary question: how to remove "learned" words or to go back to the default dictionary ? Thanks in advance for your help. --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Bernard D. <bde...@us...> - 2021-05-20 12:52:39
|
- **status**: open --> fixed --- ** [tickets:#248] Problems with the spellchecker of Alpha 9.2.2 in TeX Mode for french** **Status:** fixed **Created:** Mon Mar 29, 2021 11:23 AM UTC by Laurent PRALY **Last Updated:** Thu May 20, 2021 12:52 PM UTC **Owner:** nobody I have problems with the spellcker of Alpha 9.2.2 in TeX Mode for french. Specifically in a text in french, the job is not done correctly in presence of accents or in comments. Here are the parameters concerning spelling in my Alpha's configuration for the TeX Mode **Choose an implementatation for spellcheck:** Alpha **Alpha Preferences: "TeX" Mode > LaTeX Accents** Accent Smart Escape: Yes Accents in Comments: No Bind LaTeX Accents: No Accente Syntax: \'{e} & \oe{} **Alpha Preferences: "TeX" Mode Features** LaTeX Accents: Yes My test file is: *\documentclass[a4paper,12pt]{article} % letter \begin{document} Nous \'{e}tudions ici le bouclage dynamique de sortie qui est un sujet extr\^{e}mement extremement vaste. Nous nous li\-mi\-tons \`{a} l'\'{e}nonc\'{e} d'id\'{e}es directrices et \`{a} une pr\'{e}sentation tr\`{e}s in\'{e}gale des r\'{e}sultats, avec beaucoup de d\'{e}tails pour certains et \`{a} peine une \'{e}bauche pour d'autres. \end{document}* Here are the flagged words by Alpha after the action of "spellcheck window" letter extr extremement d'id tr For me letter should not be flagged because it is in a comment. The other flagged words show that TeX accents, as declared in the configuration, are not understood. Worse, if I use the spellchecker to correct the word extremement I get extr\^{e}mement which is correct. But if I run the spellchecker on the corrected file, the corrected word is flagged as extr I have noticed that the problem does not depend in the encoding. It is the same for UTF-8, OSX and ISO. Is there a problem with my configuration or is it a problem with the spellchecker ? Auxiliary question: how to remove "learned" words or to go back to the default dictionary ? --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Bernard D. <bde...@us...> - 2021-05-20 12:52:27
|
This is fixed now. Changes committed to the repository ([rev. 2009](https://sourceforge.net/p/alphacocoa/code/2009/)). See details in Ticket 250. --- ** [tickets:#248] Problems with the spellchecker of Alpha 9.2.2 in TeX Mode for french** **Status:** open **Created:** Mon Mar 29, 2021 11:23 AM UTC by Laurent PRALY **Last Updated:** Mon Mar 29, 2021 11:23 AM UTC **Owner:** nobody I have problems with the spellcker of Alpha 9.2.2 in TeX Mode for french. Specifically in a text in french, the job is not done correctly in presence of accents or in comments. Here are the parameters concerning spelling in my Alpha's configuration for the TeX Mode **Choose an implementatation for spellcheck:** Alpha **Alpha Preferences: "TeX" Mode > LaTeX Accents** Accent Smart Escape: Yes Accents in Comments: No Bind LaTeX Accents: No Accente Syntax: \'{e} & \oe{} **Alpha Preferences: "TeX" Mode Features** LaTeX Accents: Yes My test file is: *\documentclass[a4paper,12pt]{article} % letter \begin{document} Nous \'{e}tudions ici le bouclage dynamique de sortie qui est un sujet extr\^{e}mement extremement vaste. Nous nous li\-mi\-tons \`{a} l'\'{e}nonc\'{e} d'id\'{e}es directrices et \`{a} une pr\'{e}sentation tr\`{e}s in\'{e}gale des r\'{e}sultats, avec beaucoup de d\'{e}tails pour certains et \`{a} peine une \'{e}bauche pour d'autres. \end{document}* Here are the flagged words by Alpha after the action of "spellcheck window" letter extr extremement d'id tr For me letter should not be flagged because it is in a comment. The other flagged words show that TeX accents, as declared in the configuration, are not understood. Worse, if I use the spellchecker to correct the word extremement I get extr\^{e}mement which is correct. But if I run the spellchecker on the corrected file, the corrected word is flagged as extr I have noticed that the problem does not depend in the encoding. It is the same for UTF-8, OSX and ISO. Is there a problem with my configuration or is it a problem with the spellchecker ? Auxiliary question: how to remove "learned" words or to go back to the default dictionary ? --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Bernard D. <bde...@us...> - 2021-05-20 12:51:39
|
- **status**: open --> fixed --- ** [tickets:#250] RemReminder on ticket #248 : Problems with the spellchecker of Alpha 9.2.2 in TeX Mode for french** **Status:** fixed **Created:** Sun Apr 11, 2021 09:30 AM UTC by Laurent PRALY **Last Updated:** Thu May 20, 2021 12:51 PM UTC **Owner:** nobody Having received no comment on ticket 248, I am rewriting it here with increasing its priority to major. I have problems with the spellcker of Alpha 9.2.2 in TeX Mode for french. Specifically in a text in french, the job is not done correctly in presence of accents or in comments. Here are the parameters concerning spelling in my Alpha's configuration for the TeX Mode Choose an implementatation for spellcheck: Alpha Alpha Preferences: "TeX" Mode > LaTeX Accents Accent Smart Escape: Yes Accents in Comments: No Bind LaTeX Accents: No Accente Syntax: \'{e} & \oe{} Alpha Preferences: "TeX" Mode Features LaTeX Accents: Yes My test file is: \documentclass[a4paper,12pt] % letter \begin{document} Nous \'{e}tudions ici le bouclage dynamique de sortie qui est un sujet extr\^{e}mement extremement vaste. Nous nous li-mi-tons \`{a} l'\'{e}nonc\'{e} d'id\'{e}es directrices et \`{a} une pr\'{e}sentation tr\`{e}s in\'{e}gale des r\'{e}sultats, avec beaucoup de d\'{e}tails pour certains et \`{a} peine une \'{e}bauche pour d'autres. \end{document} After starting Alpha, I created a new file with the above content, change the mode to TeX, typed the above and recorded the file. Then Edit > Spelling > Spelcheck window flagged successively the following words, **letter** Find next **extr** Find next **extremement** Correct **d'id** Find next **tr** Find next For me **letter** should not be flagged because it is in a comment. The other flagged words show that TeX accents, as declared in the configuration, are not understood. Worse, the correction of **extremement** I get is **extr\^{e}mement** which is correct. But if I run the spellchecker on the corrected file, the corrected word is flagged as **extr** I have noticed that the problem does not depend in the encoding. It is the same for UTF-8, OSX and ISO. Is there a problem with my configuration or is it a problem with the spellchecker ? Auxiliary question: how to remove "learned" words or to go back to the default dictionary ? Thanks in advance for your help. --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Bernard D. <bde...@us...> - 2021-05-20 12:51:18
|
This is fixed now. Changes committed to the repository ([rev. 2009](https://sourceforge.net/p/alphacocoa/code/2009/)). All reported faults are resolved in the example given. Please continue to report if you experience other issues. Note that in order to avoid that the word *letter* be flagged, you can enable the latex mode preference called *Dont Spell Check Preamble*. --- ** [tickets:#250] RemReminder on ticket #248 : Problems with the spellchecker of Alpha 9.2.2 in TeX Mode for french** **Status:** open **Created:** Sun Apr 11, 2021 09:30 AM UTC by Laurent PRALY **Last Updated:** Sun Apr 11, 2021 12:48 PM UTC **Owner:** nobody Having received no comment on ticket 248, I am rewriting it here with increasing its priority to major. I have problems with the spellcker of Alpha 9.2.2 in TeX Mode for french. Specifically in a text in french, the job is not done correctly in presence of accents or in comments. Here are the parameters concerning spelling in my Alpha's configuration for the TeX Mode Choose an implementatation for spellcheck: Alpha Alpha Preferences: "TeX" Mode > LaTeX Accents Accent Smart Escape: Yes Accents in Comments: No Bind LaTeX Accents: No Accente Syntax: \'{e} & \oe{} Alpha Preferences: "TeX" Mode Features LaTeX Accents: Yes My test file is: \documentclass[a4paper,12pt] % letter \begin{document} Nous \'{e}tudions ici le bouclage dynamique de sortie qui est un sujet extr\^{e}mement extremement vaste. Nous nous li-mi-tons \`{a} l'\'{e}nonc\'{e} d'id\'{e}es directrices et \`{a} une pr\'{e}sentation tr\`{e}s in\'{e}gale des r\'{e}sultats, avec beaucoup de d\'{e}tails pour certains et \`{a} peine une \'{e}bauche pour d'autres. \end{document} After starting Alpha, I created a new file with the above content, change the mode to TeX, typed the above and recorded the file. Then Edit > Spelling > Spelcheck window flagged successively the following words, **letter** Find next **extr** Find next **extremement** Correct **d'id** Find next **tr** Find next For me **letter** should not be flagged because it is in a comment. The other flagged words show that TeX accents, as declared in the configuration, are not understood. Worse, the correction of **extremement** I get is **extr\^{e}mement** which is correct. But if I run the spellchecker on the corrected file, the corrected word is flagged as **extr** I have noticed that the problem does not depend in the encoding. It is the same for UTF-8, OSX and ISO. Is there a problem with my configuration or is it a problem with the spellchecker ? Auxiliary question: how to remove "learned" words or to go back to the default dictionary ? Thanks in advance for your help. --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Bernard D. <bde...@us...> - 2021-05-18 13:46:59
|
- **status**: open --> fixed --- ** [tickets:#252] S+/R mode - Process Current File (Cmd^T) fails** **Status:** fixed **Labels:** S+/R mode **Created:** Thu May 13, 2021 09:21 AM UTC by Fischlin Andreas **Last Updated:** Tue May 18, 2021 01:46 PM UTC **Owner:** nobody The essential menu command "S+/R -> Process Current File" of the S+/R mode fails. It does no longer source, i.e. it does not process the current file. I am sorry to lack the time right now to figure out why that is. Perhaps it is the R GUI app which has changed, but then Alpha might need to adjust what Apple Event it sends to R. In any case, INMHO the mode is crippled by this problem. Does anyone perhaps know a solution to this problem? I would greatly appreciate getting any hints on how to circumvent this if bigger modifications would be required to the mode as this is rather at the moment urgent for me. Thanks. Alpha 9.2.2 (10145) -- R 3.6.1 GUI 1.70 El Capitan build -- OS X 10.14.6 (Mojave) --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Bernard D. <bde...@us...> - 2021-05-18 13:46:37
|
So I have implemented this new behaviour in Alpha 9.2.3 (soon to be released). Marking this ticket as fixed. --- ** [tickets:#252] S+/R mode - Process Current File (Cmd^T) fails** **Status:** open **Labels:** S+/R mode **Created:** Thu May 13, 2021 09:21 AM UTC by Fischlin Andreas **Last Updated:** Sun May 16, 2021 09:59 AM UTC **Owner:** nobody The essential menu command "S+/R -> Process Current File" of the S+/R mode fails. It does no longer source, i.e. it does not process the current file. I am sorry to lack the time right now to figure out why that is. Perhaps it is the R GUI app which has changed, but then Alpha might need to adjust what Apple Event it sends to R. In any case, INMHO the mode is crippled by this problem. Does anyone perhaps know a solution to this problem? I would greatly appreciate getting any hints on how to circumvent this if bigger modifications would be required to the mode as this is rather at the moment urgent for me. Thanks. Alpha 9.2.2 (10145) -- R 3.6.1 GUI 1.70 El Capitan build -- OS X 10.14.6 (Mojave) --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Fischlin A. <afi...@us...> - 2021-05-16 09:59:28
|
Thanks a lot Bernard (merci beaucoup). It works like a charm, I just use Cmd^T (all other T related shortcuts are already in use by many other processes). Works nicely as the new Cmd^T ;-) BTW, yes, as far back as I can remember (many, many years of R use with Alpha) Cmd^T has sourced the R script. But I have to admit, I do not remember when that changed, as I have not used R since several months now. --- ** [tickets:#252] S+/R mode - Process Current File (Cmd^T) fails** **Status:** open **Labels:** S+/R mode **Created:** Thu May 13, 2021 09:21 AM UTC by Fischlin Andreas **Last Updated:** Thu May 13, 2021 02:23 PM UTC **Owner:** nobody The essential menu command "S+/R -> Process Current File" of the S+/R mode fails. It does no longer source, i.e. it does not process the current file. I am sorry to lack the time right now to figure out why that is. Perhaps it is the R GUI app which has changed, but then Alpha might need to adjust what Apple Event it sends to R. In any case, INMHO the mode is crippled by this problem. Does anyone perhaps know a solution to this problem? I would greatly appreciate getting any hints on how to circumvent this if bigger modifications would be required to the mode as this is rather at the moment urgent for me. Thanks. Alpha 9.2.2 (10145) -- R 3.6.1 GUI 1.70 El Capitan build -- OS X 10.14.6 (Mojave) --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Fischlin A. <and...@en...> - 2021-05-16 09:56:42
|
Cher Bernard, Sorry for the confusion. I have reported on my pleasure using this fix earlier. Merci beaucoup mille fois! Revisiting the site https://sourceforge.net/p/alphacocoa/tickets/252/#ef8f I detected that my reply describing what I did must have gone lost somehow. No idea when and why. In any case the new SPrefs.tcl file does now fix the situation perfectly well. BTW, I simply took away the Cmd^T from the existing mode’s menu command ‘Process Current File’, which is the only acceptable solution to me as I am already using alternative shortcuts involving T on my Mac for other purposes. For me it has to be Cmd^T. Merci! Andreas ETH Zurich Prof. em. Dr. Andreas Fischlin IPCC Vice-Chair WGII Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics CHN E 24 Universitaetstrasse 16 8092 Zurich SWITZERLAND and...@en...<mailto:and...@en...> www.sysecol.ethz.ch/people/andreas.fischlin.html<http://www.sysecol.ethz.ch/people/andreas.fischlin.hml> +41 44 633-6090 phone +41 44 633-1136 fax +41 79 595-4050 mobile Make it as simple as possible, but distrust it! ________________________________________________________________________ On 15/05/2021, at 13:11, Bernard Desgraupes <bde...@or...<mailto:bde...@or...>> wrote: Dear Andreas, have you had a chance to give a try to the code I suggested here: https://sourceforge.net/p/alphacocoa/tickets/252/#ef8f Is it a satisfactory solution ? Bernard Le 14 mai 2021 à 10:33, Fischlin Andreas via AlphaCocoa-devel <alp...@li...<mailto:alp...@li...>> a écrit : Dear Bernard, Perhaps one more thing on this: As I said initially, this may also be the result from changes in R and it could well be that Alpha’s S+/R mode is not the reason for the change in behavior. Andreas _______________________________________________ AlphaCocoa-devel mailing list Alp...@li...<mailto:Alp...@li...> https://lists.sourceforge.net/lists/listinfo/alphacocoa-devel |
From: Bernard D. <bde...@or...> - 2021-05-15 11:12:09
|
Dear Andreas, have you had a chance to give a try to the code I suggested here: https://sourceforge.net/p/alphacocoa/tickets/252/#ef8f <https://sourceforge.net/p/alphacocoa/tickets/252/#ef8f> Is it a satisfactory solution ? Bernard > Le 14 mai 2021 à 10:33, Fischlin Andreas via AlphaCocoa-devel <alp...@li...> a écrit : > > Dear Bernard, > > Perhaps one more thing on this: As I said initially, this may also be the result from changes in R and it could well be that Alpha’s S+/R mode is not the reason for the change in behavior. > > Andreas > |
From: Bernard D. <bde...@us...> - 2021-05-15 11:07:20
|
Hi Chris, thanks for reporting this. I would need something reproducible or more details about the circumstances. I have reviewed the attached file *Problem Report.txt* but my skills are insufficient to understand what is going on. Let's keep this ticket open until we know more... --- ** [tickets:#251] Strange hang** **Status:** open **Created:** Thu Apr 22, 2021 06:00 AM UTC by Chris Skeels **Last Updated:** Thu Apr 22, 2021 06:01 AM UTC **Owner:** nobody **Attachments:** - [Problem Report.txt](https://sourceforge.net/p/alphacocoa/tickets/251/attachment/Problem%20Report.txt) (3.0 MB; text/plain) Every now and then, not often, I find that Alpha hangs for no apparent reason. This most recent time I caught the report that would have been sent to Apple, in case this is of any benefit at all. It doesn't happen so often that it is a major event, but it is always annoying when it does happen. Like as not it is interaction with something else on my machine rather than Alpha itself. --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Bernard D. <bde...@or...> - 2021-05-15 10:19:46
|
Hi Joachim, this is because I specify the --slave option to setup the pipe. The options I declare are: --interactive --vanilla --slave whereas your console uses: --vanilla --no-readline --interactive I experimented removing the --slave option and indeed in that case I get the + prompt, sent back from R. I also get the initial banner which Alpha’s console did not receive because of this option. I’ll have to investigate further to see how I can best handle this. Cheers, Bernard > Le 15 mai 2021 à 11:56, Joachim Kock <ko...@ma...> a écrit : > > Ha! No, I was not aware that Alpha now has a built-in R console. > > As far as I can see, the built-in console uses more modern > Alpha console technology [console::interactive], but for some > reason it does not transmit the secondary prompt +. > > Mine does, which is strange, because my code does not do > anything in particular to achieve this. This makes me wonder > why it could be that [console::interactive] gobbles it. > > Any insight? > > (Don't spend time on it -- it works fine without the + prompt > even for incomplete commands.) > > Cheers, > Joachim. > > > > On 14/05/2021 15:06, Bernard Desgraupes wrote: >> Very nice ! >> Thanks for sharing this ! >> You know of course that Alpha does now have an internal R console very similar to yours (I see that your code predates Alpha’s). >> Cheers, >> Bernard >>> Le 13 mai 2021 à 19:36, Joachim Kock <ko...@ma...> a écrit : >>> >>> Sorry about that, the correct URL is >>> http://mat.uab.cat/~kock/tmp/R-shell-cocoa.tcl.zip >>> Joachim. >>> >>> On 13/05/2021 19:27, Bernard Desgraupes wrote: >>>> Hi Joachim, >>>> the URL below seems to be broken. I get: >>>> <<< The requested URL /~kock/www/tmp/R-shell-cocoa.tcl.zip was not found on this server. >>> >>>> Bernard >>>>> Le 13 mai 2021 à 19:02, Joachim Kock <ko...@ma...> a écrit : >>>>> >>>>> Hi all, >>>>> >>>>> for some years I have been running my own little >>>>> interface to command-line R. In addition to a plain >>>>> R console inside Alpha, the feature is that from an >>>>> R script file you can step through the commands with >>>>> shift-Return, and then that command is sent to the >>>>> console and evaluated. >>>>> >>>>> If you want to try it out, here it is. >>>>> I'll be happy to help if you have questions. >>>>> >>>>> Cheers, >>>>> Joachim. >>>>> >>>>> PS: in case the email transmission screws up the >>>>> line breaks of the script, you can also take it from >>>>> http://mat.uab.cat/~kock/www/tmp/R-shell-cocoa.tcl.zip >>>>> >>>>> >>>>> ---- >>>>> >>>>> ## -*-Tcl-*- (nowrap) >>>>> # ################################################################### >>>>> # AlphaTcl >>>>> # >>>>> # created: 2011-11-18 18:23 >>>>> # last update: 2013-01-05 18:32 >>>>> # >>>>> # File: "R-shell.tcl" >>>>> # Author: Joachim Kock <ko...@ma...> >>>>> # Description: R console (interaction with R). >>>>> # >>>>> ## >>>>> >>>>> >>>>> # Initialise namespace: >>>>> namespace eval R {} >>>>> >>>>> >>>>> >>>>> ######## Set up the R console functionality ######## >>>>> >>>>> hook::register closeHook R::properClose S >>>>> >>>>> console::create "*R console*" -mode S -attr 1 -histsize 50 \ >>>>> -fontsize 12 -g [list 1021 120 697 558] >>>>> >>>>> proc R::properClose { win } { >>>>> if { $win eq "*R console*" } { >>>>> stop >>>>> } >>>>> } >>>>> >>>>> proc R::start { } { >>>>> # We should not start a new instance, nor should we send start >>>>> # instructions to an already running instance. So check: >>>>> if { [R::isRunning] } { >>>>> console::open "*R console*" >>>>> return >>>>> } >>>>> >>>>> # Otherwise we need to really start it up: >>>>> >>>>> # Check that R is installed: >>>>> if { [regexp "^no R" [exec which R]] } { >>>>> alertnote "Could not start R." "Please check your R installation." >>>>> error "Cancel: Could not start R" >>>>> } >>>>> >>>>> variable mainPipe >>>>> variable promptPos >>>>> >>>>> # Unfortunately (standard problem) the following does not work: >>>>> # set mainPipe [open "|R --vanilla --interactive 2>&1" RDWR] >>>>> set mainPipe [open "|/bin/sh" RDWR] >>>>> fconfigure $mainPipe -buffering line -blocking 0 >>>>> >>>>> # Open the console: >>>>> console::open "*R console*" >>>>> console::strict::turnOn "*R console*" -readlineProc R::sendthis >>>>> puts $mainPipe "R --vanilla --no-readline --interactive 2>&1" >>>>> >>>>> # Set up a handler for the output: >>>>> fileevent $mainPipe readable [list R::receiveAndDisplay $mainPipe] >>>>> } >>>>> >>>>> # The error pipe error messages from R. >>>>> # The prompt is sent over stdout. >>>>> >>>>> >>>>> # Stopper: >>>>> proc R::stop { } { >>>>> # Close the pipe: >>>>> variable mainPipe >>>>> catch {close $mainPipe} >>>>> # And close the console window: >>>>> } >>>>> >>>>> # Event handler for both R::mainPipe: >>>>> proc R::receiveAndDisplay { pipe } { >>>>> if { [eof $pipe] } { >>>>> # There is nothing more to read --- just stop: >>>>> variable done 1 >>>>> stop >>>>> return >>>>> } >>>>> set res [read $pipe] >>>>> variable cmd >>>>> # Insert the result in the window: >>>>> console::strict::write "*R console*" "$res" >>>>> variable done 1 >>>>> >>>>> variable error >>>>> if { [regexp -- {(?:Syntax error|User error|Error):.*} $res error] } { >>>>> variable exitcode 1 >>>>> } else { >>>>> variable exitcode 0 >>>>> } >>>>> } >>>>> >>>>> >>>>> proc R::sendthis { win str prompt } { >>>>> variable mainPipe >>>>> variable cmd $str >>>>> puts $mainPipe $cmd >>>>> # Timeout mechanisms: We are going to wait for the variable $done. >>>>> # Make sure it is written at least ofter some time: >>>>> set timeout [after 10000 {set ::R::done "TIMEOUT"}] >>>>> vwait ::R::done >>>>> # If we have come so far there is no more need for the time bomb: >>>>> after cancel $timeout >>>>> variable done >>>>> if { [string equal $done "TIMEOUT"] } { >>>>> stop >>>>> error "TIMEOUT" >>>>> } >>>>> } >>>>> >>>>> >>>>> # This proc sends a command to the console, i.e. just writes it in the >>>>> # console window at [maxPos]. It may accept an argument, but is mostly >>>>> # used without, then it just takes the current input region. >>>>> # >>>>> # And then press the trigger for sending >>>>> # to the process (this is handled by console::strict::RETURN and >>>>> # ultimately by R::sendThis, since this proc was declared as readlineProc >>>>> # when setting up the strictness. >>>>> proc R::send {} { >>>>> if { ![isSelection] } { >>>>> selection set {*}[findEnclosingStatement] >>>>> after 100 >>>>> } >>>>> set next [selEnd] >>>>> set cmd [selection get] >>>>> # set cmd [stripComments $cmd] >>>>> set cmd [string trim $cmd] >>>>> >>>>> if { [catch {sendAndExecute $cmd} err] } { >>>>> status::msg $err >>>>> } else { >>>>> after 150 >>>>> if { [catch {nextRegion $next}] } { >>>>> goto $next >>>>> if { [pos::compare $next != [linePos start $next]] } { >>>>> # This is at file end without a new line to write on. >>>>> text insert \n >>>>> } >>>>> } >>>>> } >>>>> return "" >>>>> } >>>>> >>>>> >>>>> proc R::sendAndExecute { cmd } { >>>>> if { ![isRunning] } { >>>>> set win [win::Current] >>>>> start >>>>> bringToFront $win >>>>> } >>>>> goto -w "*R console*" [maxPos -w "*R console*"] >>>>> foreach line [split $cmd \r\n] { >>>>> text insert -w "*R console*" "$line" >>>>> console::strict::RETURN "*R console*" >>>>> } >>>>> variable exitcode >>>>> if { $exitcode } { >>>>> # There was an error >>>>> variable error >>>>> error $error >>>>> } >>>>> } >>>>> >>>>> ######## Set up the step functionality ######## >>>>> >>>>> >>>>> # This proc tries to select the enclosing complete R statement, >>>>> # except if the given position is on a blank line, in which case >>>>> # it will look for the following complete R statement. >>>>> proc R::findEnclosingStatement { {pos ""} {mpos ""}} { >>>>> if { $pos eq "" } { >>>>> set pos [getPos] >>>>> } >>>>> if { $mpos eq "" } { >>>>> set mpos [minPos] >>>>> } >>>>> # The basic algorithm is to go back to look for a line which starts >>>>> # with neither a blank nor a comment char. >>>>> if { [catch { search -f 0 -r 1 -l $mpos {^[^\s\#]} $pos } previous] } { >>>>> error "Cancelled. Could not find start of enclosing statement" >>>>> } else { >>>>> set p0 [lindex $previous 0] >>>>> } >>>>> # Now find the following such line start: >>>>> if { [pos::compare $pos == $p0] } { >>>>> set pos [pos::math $pos + 1] >>>>> } >>>>> >>>>> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >>>>> set p1 [maxPos] >>>>> } else { >>>>> set p1 [lindex $next 0] >>>>> } >>>>> # What we now have is typically too big a selection, as it will involve >>>>> # blank lines and comments following the statement. Search backwards >>>>> # from $p1 to find a nonwhite followed by some space and linebreak >>>>> if { ![catch { search -f 0 -r 1 -l $p0 {^[^\#]*[^ \t\#][ \t]*$} [pos::math $p1 -1] } pre] } { >>>>> # The search string says: look for a complete line whose last >>>>> # nonwhite is not a \# and whose previous content does contain a \# >>>>> >>>>> # JK:2018: there seems to be a problem with backward search, namely that >>>>> # the found match may extend later than the start position of the search >>>>> if { [pos::compare [lindex $pre 1] < $p1] } { >>>>> set p1 [pos::math [lindex $pre 1] + 1] >>>>> } >>>>> >>>>> } >>>>> >>>>> # The selection might also be too small, though, namely if there is >>>>> # some unbalanced parenthesis or brace >>>>> set ok 0 >>>>> while { !$ok } { >>>>> set ok 1 >>>>> set parens [search -all -n -f 1 -r 1 -l $p1 {(\{|\()} $p0] >>>>> foreach parpar $parens { >>>>> # CHANGED since search -all now returns a list of pairs JK:2018-11-05 >>>>> foreach {par0 par1} $parpar {} >>>>> set match [matchIt [lookAt $par0] $par1] >>>>> # alertnote [lookAt [lindex $par 0]] >>>>> if { [pos::compare $match >= $p1] } { >>>>> set p1 [pos::math $match + 1] >>>>> set ok 0 >>>>> } >>>>> } >>>>> } >>>>> # JK:2018: we need to include the whole line: >>>>> if { [pos::math $p1 > [linePos start $p1]] } { >>>>> set p1 [linePos next $p1] >>>>> } >>>>> return [list $p0 $p1] >>>>> } >>>>> >>>>> # Select the next input region. If no next input >>>>> # region is found, an error is raised. >>>>> proc R::nextRegion { {pos ""} } { >>>>> if { $pos eq "" } { >>>>> if { [isSelection] } { >>>>> set pos [selEnd] >>>>> } else { >>>>> set pos [pos::math [getPos] +1] >>>>> } >>>>> } >>>>> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >>>>> error "Cancelled. Could not find next statement" >>>>> } >>>>> selection set {*}[findEnclosingStatement [lindex $next 1]] >>>>> # If we are too close to the bottom of the window...: >>>>> getWinInfo -w [win::Current] a >>>>> set bottomline [expr {$a(currline) + $a(linesdisp) - 1}] >>>>> set thisline [lindex [posToRowCol -w [win::Current] [selEnd]] 0] >>>>> if { [expr {$bottomline - $thisline}] < 4 } { >>>>> centerRedraw >>>>> } >>>>> } >>>>> >>>>> # Handle the enter key in a source window. >>>>> # (The enter key in the console is handled by the general strictshell bindtag.) >>>>> proc R::enter {} { >>>>> if { ![isRunning] } { >>>>> set win [win::Current] >>>>> start >>>>> bringToFront $win >>>>> nextRegion >>>>> } else { >>>>> send >>>>> variable exitcode >>>>> if { $exitcode } { >>>>> # There was an error >>>>> variable error >>>>> status::msg $error >>>>> beep >>>>> } >>>>> } >>>>> } >>>>> >>>>> # Enter (both numeric block and iBook keyboard): >>>>> binding create -tag S {v Enter} ::R::enter >>>>> binding create -tag S {v 0x34} ::R::enter >>>>> >>>>> # Opt-ctrl-Downarrow >>>>> binding create -tag S {ozv 0x7d} ::R::nextRegion >>>>> binding create -tag S {ozv Down} ::R::nextRegion >>>>> >>>>> >>>>> proc R::isRunning {} { >>>>> # A better check should be performed... >>>>> return [win::Exists "*R console*"] >>>>> } >>>>> >>>>> # # Auxiliary proc, to avoid sending comments to the console. >>>>> # proc R::stripComments { txt } { >>>>> # set noOpeningOrClosing {(?:[^\(\*]|[\(][^\*]|[\*][^\)])*} >>>>> # # This means: we don't accept ( or * >>>>> # # except ( followed by anything else than * >>>>> # # and except * followed by anything else than ) >>>>> # append commentExpr {\(\*} ${noOpeningOrClosing} {\*+\)} >>>>> # # Note the plus: it is necessary to match a comment ending with **) >>>>> # set i 0 >>>>> # while { [regsub -- $commentExpr $txt "" txt] } { >>>>> # incr i >>>>> # } >>>>> # set res "" >>>>> # foreach line [split $txt \r\n] { >>>>> # if { ![string is space $line] } { >>>>> # append res $line \r >>>>> # # Note that R is happiest if it gets carriage returns. >>>>> # # If it gets newlines, it will write a new prompt for each >>>>> # # newline. >>>>> # } >>>>> # } >>>>> # return $res >>>>> # } >>>>> # >>>>> >>> > |
From: Joachim K. <ko...@ma...> - 2021-05-15 09:56:14
|
Ha! No, I was not aware that Alpha now has a built-in R console. As far as I can see, the built-in console uses more modern Alpha console technology [console::interactive], but for some reason it does not transmit the secondary prompt +. Mine does, which is strange, because my code does not do anything in particular to achieve this. This makes me wonder why it could be that [console::interactive] gobbles it. Any insight? (Don't spend time on it -- it works fine without the + prompt even for incomplete commands.) Cheers, Joachim. On 14/05/2021 15:06, Bernard Desgraupes wrote: > Very nice ! > Thanks for sharing this ! > > You know of course that Alpha does now have an internal R console very similar to yours (I see that your code predates Alpha’s). > > Cheers, > Bernard > >> Le 13 mai 2021 à 19:36, Joachim Kock <ko...@ma...> a écrit : >> >> Sorry about that, the correct URL is >> http://mat.uab.cat/~kock/tmp/R-shell-cocoa.tcl.zip >> Joachim. >> >> On 13/05/2021 19:27, Bernard Desgraupes wrote: >>> Hi Joachim, >>> the URL below seems to be broken. I get: >>> <<< The requested URL /~kock/www/tmp/R-shell-cocoa.tcl.zip was not found on this server. >>> >>> Bernard >>>> Le 13 mai 2021 à 19:02, Joachim Kock <ko...@ma...> a écrit : >>>> >>>> Hi all, >>>> >>>> for some years I have been running my own little >>>> interface to command-line R. In addition to a plain >>>> R console inside Alpha, the feature is that from an >>>> R script file you can step through the commands with >>>> shift-Return, and then that command is sent to the >>>> console and evaluated. >>>> >>>> If you want to try it out, here it is. >>>> I'll be happy to help if you have questions. >>>> >>>> Cheers, >>>> Joachim. >>>> >>>> PS: in case the email transmission screws up the >>>> line breaks of the script, you can also take it from >>>> http://mat.uab.cat/~kock/www/tmp/R-shell-cocoa.tcl.zip >>>> >>>> >>>> ---- >>>> >>>> ## -*-Tcl-*- (nowrap) >>>> # ################################################################### >>>> # AlphaTcl >>>> # >>>> # created: 2011-11-18 18:23 >>>> # last update: 2013-01-05 18:32 >>>> # >>>> # File: "R-shell.tcl" >>>> # Author: Joachim Kock <ko...@ma...> >>>> # Description: R console (interaction with R). >>>> # >>>> ## >>>> >>>> >>>> # Initialise namespace: >>>> namespace eval R {} >>>> >>>> >>>> >>>> ######## Set up the R console functionality ######## >>>> >>>> hook::register closeHook R::properClose S >>>> >>>> console::create "*R console*" -mode S -attr 1 -histsize 50 \ >>>> -fontsize 12 -g [list 1021 120 697 558] >>>> >>>> proc R::properClose { win } { >>>> if { $win eq "*R console*" } { >>>> stop >>>> } >>>> } >>>> >>>> proc R::start { } { >>>> # We should not start a new instance, nor should we send start >>>> # instructions to an already running instance. So check: >>>> if { [R::isRunning] } { >>>> console::open "*R console*" >>>> return >>>> } >>>> >>>> # Otherwise we need to really start it up: >>>> >>>> # Check that R is installed: >>>> if { [regexp "^no R" [exec which R]] } { >>>> alertnote "Could not start R." "Please check your R installation." >>>> error "Cancel: Could not start R" >>>> } >>>> >>>> variable mainPipe >>>> variable promptPos >>>> >>>> # Unfortunately (standard problem) the following does not work: >>>> # set mainPipe [open "|R --vanilla --interactive 2>&1" RDWR] >>>> set mainPipe [open "|/bin/sh" RDWR] >>>> fconfigure $mainPipe -buffering line -blocking 0 >>>> >>>> # Open the console: >>>> console::open "*R console*" >>>> console::strict::turnOn "*R console*" -readlineProc R::sendthis >>>> puts $mainPipe "R --vanilla --no-readline --interactive 2>&1" >>>> >>>> # Set up a handler for the output: >>>> fileevent $mainPipe readable [list R::receiveAndDisplay $mainPipe] >>>> } >>>> >>>> # The error pipe error messages from R. >>>> # The prompt is sent over stdout. >>>> >>>> >>>> # Stopper: >>>> proc R::stop { } { >>>> # Close the pipe: >>>> variable mainPipe >>>> catch {close $mainPipe} >>>> # And close the console window: >>>> } >>>> >>>> # Event handler for both R::mainPipe: >>>> proc R::receiveAndDisplay { pipe } { >>>> if { [eof $pipe] } { >>>> # There is nothing more to read --- just stop: >>>> variable done 1 >>>> stop >>>> return >>>> } >>>> set res [read $pipe] >>>> variable cmd >>>> # Insert the result in the window: >>>> console::strict::write "*R console*" "$res" >>>> variable done 1 >>>> >>>> variable error >>>> if { [regexp -- {(?:Syntax error|User error|Error):.*} $res error] } { >>>> variable exitcode 1 >>>> } else { >>>> variable exitcode 0 >>>> } >>>> } >>>> >>>> >>>> proc R::sendthis { win str prompt } { >>>> variable mainPipe >>>> variable cmd $str >>>> puts $mainPipe $cmd >>>> # Timeout mechanisms: We are going to wait for the variable $done. >>>> # Make sure it is written at least ofter some time: >>>> set timeout [after 10000 {set ::R::done "TIMEOUT"}] >>>> vwait ::R::done >>>> # If we have come so far there is no more need for the time bomb: >>>> after cancel $timeout >>>> variable done >>>> if { [string equal $done "TIMEOUT"] } { >>>> stop >>>> error "TIMEOUT" >>>> } >>>> } >>>> >>>> >>>> # This proc sends a command to the console, i.e. just writes it in the >>>> # console window at [maxPos]. It may accept an argument, but is mostly >>>> # used without, then it just takes the current input region. >>>> # >>>> # And then press the trigger for sending >>>> # to the process (this is handled by console::strict::RETURN and >>>> # ultimately by R::sendThis, since this proc was declared as readlineProc >>>> # when setting up the strictness. >>>> proc R::send {} { >>>> if { ![isSelection] } { >>>> selection set {*}[findEnclosingStatement] >>>> after 100 >>>> } >>>> set next [selEnd] >>>> set cmd [selection get] >>>> # set cmd [stripComments $cmd] >>>> set cmd [string trim $cmd] >>>> >>>> if { [catch {sendAndExecute $cmd} err] } { >>>> status::msg $err >>>> } else { >>>> after 150 >>>> if { [catch {nextRegion $next}] } { >>>> goto $next >>>> if { [pos::compare $next != [linePos start $next]] } { >>>> # This is at file end without a new line to write on. >>>> text insert \n >>>> } >>>> } >>>> } >>>> return "" >>>> } >>>> >>>> >>>> proc R::sendAndExecute { cmd } { >>>> if { ![isRunning] } { >>>> set win [win::Current] >>>> start >>>> bringToFront $win >>>> } >>>> goto -w "*R console*" [maxPos -w "*R console*"] >>>> foreach line [split $cmd \r\n] { >>>> text insert -w "*R console*" "$line" >>>> console::strict::RETURN "*R console*" >>>> } >>>> variable exitcode >>>> if { $exitcode } { >>>> # There was an error >>>> variable error >>>> error $error >>>> } >>>> } >>>> >>>> ######## Set up the step functionality ######## >>>> >>>> >>>> # This proc tries to select the enclosing complete R statement, >>>> # except if the given position is on a blank line, in which case >>>> # it will look for the following complete R statement. >>>> proc R::findEnclosingStatement { {pos ""} {mpos ""}} { >>>> if { $pos eq "" } { >>>> set pos [getPos] >>>> } >>>> if { $mpos eq "" } { >>>> set mpos [minPos] >>>> } >>>> # The basic algorithm is to go back to look for a line which starts >>>> # with neither a blank nor a comment char. >>>> if { [catch { search -f 0 -r 1 -l $mpos {^[^\s\#]} $pos } previous] } { >>>> error "Cancelled. Could not find start of enclosing statement" >>>> } else { >>>> set p0 [lindex $previous 0] >>>> } >>>> # Now find the following such line start: >>>> if { [pos::compare $pos == $p0] } { >>>> set pos [pos::math $pos + 1] >>>> } >>>> >>>> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >>>> set p1 [maxPos] >>>> } else { >>>> set p1 [lindex $next 0] >>>> } >>>> # What we now have is typically too big a selection, as it will involve >>>> # blank lines and comments following the statement. Search backwards >>>> # from $p1 to find a nonwhite followed by some space and linebreak >>>> if { ![catch { search -f 0 -r 1 -l $p0 {^[^\#]*[^ \t\#][ \t]*$} [pos::math $p1 -1] } pre] } { >>>> # The search string says: look for a complete line whose last >>>> # nonwhite is not a \# and whose previous content does contain a \# >>>> >>>> # JK:2018: there seems to be a problem with backward search, namely that >>>> # the found match may extend later than the start position of the search >>>> if { [pos::compare [lindex $pre 1] < $p1] } { >>>> set p1 [pos::math [lindex $pre 1] + 1] >>>> } >>>> >>>> } >>>> >>>> # The selection might also be too small, though, namely if there is >>>> # some unbalanced parenthesis or brace >>>> set ok 0 >>>> while { !$ok } { >>>> set ok 1 >>>> set parens [search -all -n -f 1 -r 1 -l $p1 {(\{|\()} $p0] >>>> foreach parpar $parens { >>>> # CHANGED since search -all now returns a list of pairs JK:2018-11-05 >>>> foreach {par0 par1} $parpar {} >>>> set match [matchIt [lookAt $par0] $par1] >>>> # alertnote [lookAt [lindex $par 0]] >>>> if { [pos::compare $match >= $p1] } { >>>> set p1 [pos::math $match + 1] >>>> set ok 0 >>>> } >>>> } >>>> } >>>> # JK:2018: we need to include the whole line: >>>> if { [pos::math $p1 > [linePos start $p1]] } { >>>> set p1 [linePos next $p1] >>>> } >>>> return [list $p0 $p1] >>>> } >>>> >>>> # Select the next input region. If no next input >>>> # region is found, an error is raised. >>>> proc R::nextRegion { {pos ""} } { >>>> if { $pos eq "" } { >>>> if { [isSelection] } { >>>> set pos [selEnd] >>>> } else { >>>> set pos [pos::math [getPos] +1] >>>> } >>>> } >>>> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >>>> error "Cancelled. Could not find next statement" >>>> } >>>> selection set {*}[findEnclosingStatement [lindex $next 1]] >>>> # If we are too close to the bottom of the window...: >>>> getWinInfo -w [win::Current] a >>>> set bottomline [expr {$a(currline) + $a(linesdisp) - 1}] >>>> set thisline [lindex [posToRowCol -w [win::Current] [selEnd]] 0] >>>> if { [expr {$bottomline - $thisline}] < 4 } { >>>> centerRedraw >>>> } >>>> } >>>> >>>> # Handle the enter key in a source window. >>>> # (The enter key in the console is handled by the general strictshell bindtag.) >>>> proc R::enter {} { >>>> if { ![isRunning] } { >>>> set win [win::Current] >>>> start >>>> bringToFront $win >>>> nextRegion >>>> } else { >>>> send >>>> variable exitcode >>>> if { $exitcode } { >>>> # There was an error >>>> variable error >>>> status::msg $error >>>> beep >>>> } >>>> } >>>> } >>>> >>>> # Enter (both numeric block and iBook keyboard): >>>> binding create -tag S {v Enter} ::R::enter >>>> binding create -tag S {v 0x34} ::R::enter >>>> >>>> # Opt-ctrl-Downarrow >>>> binding create -tag S {ozv 0x7d} ::R::nextRegion >>>> binding create -tag S {ozv Down} ::R::nextRegion >>>> >>>> >>>> proc R::isRunning {} { >>>> # A better check should be performed... >>>> return [win::Exists "*R console*"] >>>> } >>>> >>>> # # Auxiliary proc, to avoid sending comments to the console. >>>> # proc R::stripComments { txt } { >>>> # set noOpeningOrClosing {(?:[^\(\*]|[\(][^\*]|[\*][^\)])*} >>>> # # This means: we don't accept ( or * >>>> # # except ( followed by anything else than * >>>> # # and except * followed by anything else than ) >>>> # append commentExpr {\(\*} ${noOpeningOrClosing} {\*+\)} >>>> # # Note the plus: it is necessary to match a comment ending with **) >>>> # set i 0 >>>> # while { [regsub -- $commentExpr $txt "" txt] } { >>>> # incr i >>>> # } >>>> # set res "" >>>> # foreach line [split $txt \r\n] { >>>> # if { ![string is space $line] } { >>>> # append res $line \r >>>> # # Note that R is happiest if it gets carriage returns. >>>> # # If it gets newlines, it will write a new prompt for each >>>> # # newline. >>>> # } >>>> # } >>>> # return $res >>>> # } >>>> # >>>> >> > |
From: Bernard D. <bde...@or...> - 2021-05-14 13:06:33
|
Very nice ! Thanks for sharing this ! You know of course that Alpha does now have an internal R console very similar to yours (I see that your code predates Alpha’s). Cheers, Bernard > Le 13 mai 2021 à 19:36, Joachim Kock <ko...@ma...> a écrit : > > Sorry about that, the correct URL is > http://mat.uab.cat/~kock/tmp/R-shell-cocoa.tcl.zip > Joachim. > > On 13/05/2021 19:27, Bernard Desgraupes wrote: >> Hi Joachim, >> the URL below seems to be broken. I get: >> <<< The requested URL /~kock/www/tmp/R-shell-cocoa.tcl.zip was not found on this server. >>> >> Bernard >>> Le 13 mai 2021 à 19:02, Joachim Kock <ko...@ma...> a écrit : >>> >>> Hi all, >>> >>> for some years I have been running my own little >>> interface to command-line R. In addition to a plain >>> R console inside Alpha, the feature is that from an >>> R script file you can step through the commands with >>> shift-Return, and then that command is sent to the >>> console and evaluated. >>> >>> If you want to try it out, here it is. >>> I'll be happy to help if you have questions. >>> >>> Cheers, >>> Joachim. >>> >>> PS: in case the email transmission screws up the >>> line breaks of the script, you can also take it from >>> http://mat.uab.cat/~kock/www/tmp/R-shell-cocoa.tcl.zip >>> >>> >>> ---- >>> >>> ## -*-Tcl-*- (nowrap) >>> # ################################################################### >>> # AlphaTcl >>> # >>> # created: 2011-11-18 18:23 >>> # last update: 2013-01-05 18:32 >>> # >>> # File: "R-shell.tcl" >>> # Author: Joachim Kock <ko...@ma...> >>> # Description: R console (interaction with R). >>> # >>> ## >>> >>> >>> # Initialise namespace: >>> namespace eval R {} >>> >>> >>> >>> ######## Set up the R console functionality ######## >>> >>> hook::register closeHook R::properClose S >>> >>> console::create "*R console*" -mode S -attr 1 -histsize 50 \ >>> -fontsize 12 -g [list 1021 120 697 558] >>> >>> proc R::properClose { win } { >>> if { $win eq "*R console*" } { >>> stop >>> } >>> } >>> >>> proc R::start { } { >>> # We should not start a new instance, nor should we send start >>> # instructions to an already running instance. So check: >>> if { [R::isRunning] } { >>> console::open "*R console*" >>> return >>> } >>> >>> # Otherwise we need to really start it up: >>> >>> # Check that R is installed: >>> if { [regexp "^no R" [exec which R]] } { >>> alertnote "Could not start R." "Please check your R installation." >>> error "Cancel: Could not start R" >>> } >>> >>> variable mainPipe >>> variable promptPos >>> >>> # Unfortunately (standard problem) the following does not work: >>> # set mainPipe [open "|R --vanilla --interactive 2>&1" RDWR] >>> set mainPipe [open "|/bin/sh" RDWR] >>> fconfigure $mainPipe -buffering line -blocking 0 >>> >>> # Open the console: >>> console::open "*R console*" >>> console::strict::turnOn "*R console*" -readlineProc R::sendthis >>> puts $mainPipe "R --vanilla --no-readline --interactive 2>&1" >>> >>> # Set up a handler for the output: >>> fileevent $mainPipe readable [list R::receiveAndDisplay $mainPipe] >>> } >>> >>> # The error pipe error messages from R. >>> # The prompt is sent over stdout. >>> >>> >>> # Stopper: >>> proc R::stop { } { >>> # Close the pipe: >>> variable mainPipe >>> catch {close $mainPipe} >>> # And close the console window: >>> } >>> >>> # Event handler for both R::mainPipe: >>> proc R::receiveAndDisplay { pipe } { >>> if { [eof $pipe] } { >>> # There is nothing more to read --- just stop: >>> variable done 1 >>> stop >>> return >>> } >>> set res [read $pipe] >>> variable cmd >>> # Insert the result in the window: >>> console::strict::write "*R console*" "$res" >>> variable done 1 >>> >>> variable error >>> if { [regexp -- {(?:Syntax error|User error|Error):.*} $res error] } { >>> variable exitcode 1 >>> } else { >>> variable exitcode 0 >>> } >>> } >>> >>> >>> proc R::sendthis { win str prompt } { >>> variable mainPipe >>> variable cmd $str >>> puts $mainPipe $cmd >>> # Timeout mechanisms: We are going to wait for the variable $done. >>> # Make sure it is written at least ofter some time: >>> set timeout [after 10000 {set ::R::done "TIMEOUT"}] >>> vwait ::R::done >>> # If we have come so far there is no more need for the time bomb: >>> after cancel $timeout >>> variable done >>> if { [string equal $done "TIMEOUT"] } { >>> stop >>> error "TIMEOUT" >>> } >>> } >>> >>> >>> # This proc sends a command to the console, i.e. just writes it in the >>> # console window at [maxPos]. It may accept an argument, but is mostly >>> # used without, then it just takes the current input region. >>> # >>> # And then press the trigger for sending >>> # to the process (this is handled by console::strict::RETURN and >>> # ultimately by R::sendThis, since this proc was declared as readlineProc >>> # when setting up the strictness. >>> proc R::send {} { >>> if { ![isSelection] } { >>> selection set {*}[findEnclosingStatement] >>> after 100 >>> } >>> set next [selEnd] >>> set cmd [selection get] >>> # set cmd [stripComments $cmd] >>> set cmd [string trim $cmd] >>> >>> if { [catch {sendAndExecute $cmd} err] } { >>> status::msg $err >>> } else { >>> after 150 >>> if { [catch {nextRegion $next}] } { >>> goto $next >>> if { [pos::compare $next != [linePos start $next]] } { >>> # This is at file end without a new line to write on. >>> text insert \n >>> } >>> } >>> } >>> return "" >>> } >>> >>> >>> proc R::sendAndExecute { cmd } { >>> if { ![isRunning] } { >>> set win [win::Current] >>> start >>> bringToFront $win >>> } >>> goto -w "*R console*" [maxPos -w "*R console*"] >>> foreach line [split $cmd \r\n] { >>> text insert -w "*R console*" "$line" >>> console::strict::RETURN "*R console*" >>> } >>> variable exitcode >>> if { $exitcode } { >>> # There was an error >>> variable error >>> error $error >>> } >>> } >>> >>> ######## Set up the step functionality ######## >>> >>> >>> # This proc tries to select the enclosing complete R statement, >>> # except if the given position is on a blank line, in which case >>> # it will look for the following complete R statement. >>> proc R::findEnclosingStatement { {pos ""} {mpos ""}} { >>> if { $pos eq "" } { >>> set pos [getPos] >>> } >>> if { $mpos eq "" } { >>> set mpos [minPos] >>> } >>> # The basic algorithm is to go back to look for a line which starts >>> # with neither a blank nor a comment char. >>> if { [catch { search -f 0 -r 1 -l $mpos {^[^\s\#]} $pos } previous] } { >>> error "Cancelled. Could not find start of enclosing statement" >>> } else { >>> set p0 [lindex $previous 0] >>> } >>> # Now find the following such line start: >>> if { [pos::compare $pos == $p0] } { >>> set pos [pos::math $pos + 1] >>> } >>> >>> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >>> set p1 [maxPos] >>> } else { >>> set p1 [lindex $next 0] >>> } >>> # What we now have is typically too big a selection, as it will involve >>> # blank lines and comments following the statement. Search backwards >>> # from $p1 to find a nonwhite followed by some space and linebreak >>> if { ![catch { search -f 0 -r 1 -l $p0 {^[^\#]*[^ \t\#][ \t]*$} [pos::math $p1 -1] } pre] } { >>> # The search string says: look for a complete line whose last >>> # nonwhite is not a \# and whose previous content does contain a \# >>> >>> # JK:2018: there seems to be a problem with backward search, namely that >>> # the found match may extend later than the start position of the search >>> if { [pos::compare [lindex $pre 1] < $p1] } { >>> set p1 [pos::math [lindex $pre 1] + 1] >>> } >>> >>> } >>> >>> # The selection might also be too small, though, namely if there is >>> # some unbalanced parenthesis or brace >>> set ok 0 >>> while { !$ok } { >>> set ok 1 >>> set parens [search -all -n -f 1 -r 1 -l $p1 {(\{|\()} $p0] >>> foreach parpar $parens { >>> # CHANGED since search -all now returns a list of pairs JK:2018-11-05 >>> foreach {par0 par1} $parpar {} >>> set match [matchIt [lookAt $par0] $par1] >>> # alertnote [lookAt [lindex $par 0]] >>> if { [pos::compare $match >= $p1] } { >>> set p1 [pos::math $match + 1] >>> set ok 0 >>> } >>> } >>> } >>> # JK:2018: we need to include the whole line: >>> if { [pos::math $p1 > [linePos start $p1]] } { >>> set p1 [linePos next $p1] >>> } >>> return [list $p0 $p1] >>> } >>> >>> # Select the next input region. If no next input >>> # region is found, an error is raised. >>> proc R::nextRegion { {pos ""} } { >>> if { $pos eq "" } { >>> if { [isSelection] } { >>> set pos [selEnd] >>> } else { >>> set pos [pos::math [getPos] +1] >>> } >>> } >>> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >>> error "Cancelled. Could not find next statement" >>> } >>> selection set {*}[findEnclosingStatement [lindex $next 1]] >>> # If we are too close to the bottom of the window...: >>> getWinInfo -w [win::Current] a >>> set bottomline [expr {$a(currline) + $a(linesdisp) - 1}] >>> set thisline [lindex [posToRowCol -w [win::Current] [selEnd]] 0] >>> if { [expr {$bottomline - $thisline}] < 4 } { >>> centerRedraw >>> } >>> } >>> >>> # Handle the enter key in a source window. >>> # (The enter key in the console is handled by the general strictshell bindtag.) >>> proc R::enter {} { >>> if { ![isRunning] } { >>> set win [win::Current] >>> start >>> bringToFront $win >>> nextRegion >>> } else { >>> send >>> variable exitcode >>> if { $exitcode } { >>> # There was an error >>> variable error >>> status::msg $error >>> beep >>> } >>> } >>> } >>> >>> # Enter (both numeric block and iBook keyboard): >>> binding create -tag S {v Enter} ::R::enter >>> binding create -tag S {v 0x34} ::R::enter >>> >>> # Opt-ctrl-Downarrow >>> binding create -tag S {ozv 0x7d} ::R::nextRegion >>> binding create -tag S {ozv Down} ::R::nextRegion >>> >>> >>> proc R::isRunning {} { >>> # A better check should be performed... >>> return [win::Exists "*R console*"] >>> } >>> >>> # # Auxiliary proc, to avoid sending comments to the console. >>> # proc R::stripComments { txt } { >>> # set noOpeningOrClosing {(?:[^\(\*]|[\(][^\*]|[\*][^\)])*} >>> # # This means: we don't accept ( or * >>> # # except ( followed by anything else than * >>> # # and except * followed by anything else than ) >>> # append commentExpr {\(\*} ${noOpeningOrClosing} {\*+\)} >>> # # Note the plus: it is necessary to match a comment ending with **) >>> # set i 0 >>> # while { [regsub -- $commentExpr $txt "" txt] } { >>> # incr i >>> # } >>> # set res "" >>> # foreach line [split $txt \r\n] { >>> # if { ![string is space $line] } { >>> # append res $line \r >>> # # Note that R is happiest if it gets carriage returns. >>> # # If it gets newlines, it will write a new prompt for each >>> # # newline. >>> # } >>> # } >>> # return $res >>> # } >>> # >>> > |
From: Bernard D. <bde...@or...> - 2021-05-14 12:59:14
|
Hi Eberhard, here is a little proc that seems to do the job (that is to say, executing an R script with the R command line instead of the R.app or RStudio GUIs): proc S::sourceInConsole {} { global SmodeVars variable consoleName set f [win::Current] if {$f ne ""} { if {[winDirty] && [askyesno \ "Do you want to save the file before sourcing it?"]} { save } S::displayConsole console::interactive::consoleExec $consoleName "source(\"$f\")" } return } You can bind it to command-T like this binding create -tag S {c 'T'} S::sourceInConsole It displays its output in Alpha’s internal R console. Copy this code in your SPrefs.tcl file, quit and relaunch. You can use the Set Tool command in R mode’s menu if you need to set an unusual path for your R command line. Cheers, Bernard > Le 13 mai 2021 à 19:08, Dr Eberhard W Lisse <el...@li...> a écrit : > > Bernard > > TextMate2 opens (on CMD-R) another window (R TextMate Runtime) and > (probably) executes a > > source("filename.R", echo=TRUE) > > the output of which shows up in the Runtime window. I haven't tried > doing it on R Code in an unnamed buffer but would assume that it would > ask me to save it into a file and then does the above :-)-O. Something > similar for an unsaved buffer/file ((Ask to) Save first, then run R) > > That would most certainly do it for me :-)-O > > greetings, el > > On 2021-05-13 16:34 , Bernard Desgraupes wrote: >> Hi Eberhard, >> the commands « Process Current File » and « Process Selection » in >> Alpha’s R menu are meant to work with the GUI versions of R (either >> R.app or RStudio). Communication goes through AppleEvents. So the >> services in Helper Apps expect you to choose one of these >> applications. >> The R command line does not understand Apple Events. What you want to >> achieve is certainly feasible and could be implemented using Tcl’s >> exec command. >> But how (or where) would you expect the output of R’s calculations to >> be sent back ? >> Cheers, >> Bernard > [...] > > -- > Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist > el...@li... / * | Telephone: +264 81 124 6733 (cell) > PO Box 8421 Bachbrecht \ / If this email is signed with GPG/PGP > 10007, Namibia ;____/ Sect 20 of Act No. 4 of 2019 may apply |
From: Fischlin A. <afi...@us...> - 2021-05-14 08:33:03
|
Dear Bernard, Perhaps one more thing on this: As I said initially, this may also be the result from changes in R and it could well be that Alpha’s S+/R mode is not the reason for the change in behavior. Andreas ETH Zurich Prof. em. Dr. Andreas Fischlin IPCC Vice-Chair WGII Systems Ecology - Institute of Biogeochemistry and Pollutant Dynamics CHN E 24 Universitaetstrasse 16 8092 Zurich SWITZERLAND and...@en...<mailto:and...@en...> www.sysecol.ethz.ch/people/andreas.fischlin.html<http://www.sysecol.ethz.ch/people/andreas.fischlin.hml> +41 44 633-6090 phone +41 44 633-1136 fax +41 79 595-4050 mobile Make it as simple as possible, but distrust it! ________________________________________________________________________ On 13/05/2021, at 16:23, Bernard Desgraupes <bde...@us...<mailto:bde...@us...>> wrote: I'm not sure what you call "previous behavior" since Alpha's R mode has been working like this for several years now. Anyway, what you want to achieve is quite simple to implement. Here is an implementation that you can copy in your file SPrefs.tcl : proc S::sourceCurrentScript {} { global SmodeVars mode set f [win::Current] if {$f eq ""} { return } if {$mode ne "S"} { alertnote "Current file is not in S+/R mode." } if {[winDirty] && [askyesno \ "Do you want to save the file before sending it to $SmodeVars(rApp)?"]} { save } if {$SmodeVars(stayInAlpha)} { app::launchBack [S::bundleID] } else { app::launchFore [S::bundleID] } xserv::invoke sourceRFile -file $f return } binding create -tag S {coz 'T'} S::sourceCurrentScript The last line defines a ctrl-opt-cmd T binding to this new proc called S::sourceCurrentScript. After you copy this in your file SPrefs.tcl, then quit Alpha and relaunch it: now you can just press ctrl-opt-cmd T to get your current file sent to R.app as a source command. Whether this new implementation should become the default for the Process Current File command in Alpha's R menu may be debated. I have no objection: the current behaviour could be handled by the Process Selection command when the selection is ... empty (!). ________________________________ [tickets:#252]<https://sourceforge.net/p/alphacocoa/tickets/252/> S+/R mode - Process Current File (Cmd^T) fails Status: open Labels: S+/R mode Created: Thu May 13, 2021 09:21 AM UTC by Fischlin Andreas Last Updated: Thu May 13, 2021 11:46 AM UTC Owner: nobody The essential menu command "S+/R -> Process Current File" of the S+/R mode fails. It does no longer source, i.e. it does not process the current file. I am sorry to lack the time right now to figure out why that is. Perhaps it is the R GUI app which has changed, but then Alpha might need to adjust what Apple Event it sends to R. In any case, INMHO the mode is crippled by this problem. Does anyone perhaps know a solution to this problem? I would greatly appreciate getting any hints on how to circumvent this if bigger modifications would be required to the mode as this is rather at the moment urgent for me. Thanks. Alpha 9.2.2 (10145) -- R 3.6.1 GUI 1.70 El Capitan build -- OS X 10.14.6 (Mojave) ________________________________ Sent from sourceforge.net<http://sourceforge.net> because you indicated interest in https://sourceforge.net/p/alphacocoa/tickets/252/ To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/ --- ** [tickets:#252] S+/R mode - Process Current File (Cmd^T) fails** **Status:** open **Labels:** S+/R mode **Created:** Thu May 13, 2021 09:21 AM UTC by Fischlin Andreas **Last Updated:** Thu May 13, 2021 02:23 PM UTC **Owner:** nobody The essential menu command "S+/R -> Process Current File" of the S+/R mode fails. It does no longer source, i.e. it does not process the current file. I am sorry to lack the time right now to figure out why that is. Perhaps it is the R GUI app which has changed, but then Alpha might need to adjust what Apple Event it sends to R. In any case, INMHO the mode is crippled by this problem. Does anyone perhaps know a solution to this problem? I would greatly appreciate getting any hints on how to circumvent this if bigger modifications would be required to the mode as this is rather at the moment urgent for me. Thanks. Alpha 9.2.2 (10145) -- R 3.6.1 GUI 1.70 El Capitan build -- OS X 10.14.6 (Mojave) --- Sent from sourceforge.net because alp...@li... is subscribed to https://sourceforge.net/p/alphacocoa/tickets/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/alphacocoa/admin/tickets/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |
From: Joachim K. <ko...@ma...> - 2021-05-13 17:36:40
|
Sorry about that, the correct URL is http://mat.uab.cat/~kock/tmp/R-shell-cocoa.tcl.zip Joachim. On 13/05/2021 19:27, Bernard Desgraupes wrote: > Hi Joachim, > > the URL below seems to be broken. I get: > <<< The requested URL /~kock/www/tmp/R-shell-cocoa.tcl.zip was not found on this server. >>> > > Bernard > > >> Le 13 mai 2021 à 19:02, Joachim Kock <ko...@ma...> a écrit : >> >> Hi all, >> >> for some years I have been running my own little >> interface to command-line R. In addition to a plain >> R console inside Alpha, the feature is that from an >> R script file you can step through the commands with >> shift-Return, and then that command is sent to the >> console and evaluated. >> >> If you want to try it out, here it is. >> I'll be happy to help if you have questions. >> >> Cheers, >> Joachim. >> >> PS: in case the email transmission screws up the >> line breaks of the script, you can also take it from >> http://mat.uab.cat/~kock/www/tmp/R-shell-cocoa.tcl.zip >> >> >> ---- >> >> ## -*-Tcl-*- (nowrap) >> # ################################################################### >> # AlphaTcl >> # >> # created: 2011-11-18 18:23 >> # last update: 2013-01-05 18:32 >> # >> # File: "R-shell.tcl" >> # Author: Joachim Kock <ko...@ma...> >> # Description: R console (interaction with R). >> # >> ## >> >> >> # Initialise namespace: >> namespace eval R {} >> >> >> >> ######## Set up the R console functionality ######## >> >> hook::register closeHook R::properClose S >> >> console::create "*R console*" -mode S -attr 1 -histsize 50 \ >> -fontsize 12 -g [list 1021 120 697 558] >> >> proc R::properClose { win } { >> if { $win eq "*R console*" } { >> stop >> } >> } >> >> proc R::start { } { >> # We should not start a new instance, nor should we send start >> # instructions to an already running instance. So check: >> if { [R::isRunning] } { >> console::open "*R console*" >> return >> } >> >> # Otherwise we need to really start it up: >> >> # Check that R is installed: >> if { [regexp "^no R" [exec which R]] } { >> alertnote "Could not start R." "Please check your R installation." >> error "Cancel: Could not start R" >> } >> >> variable mainPipe >> variable promptPos >> >> # Unfortunately (standard problem) the following does not work: >> # set mainPipe [open "|R --vanilla --interactive 2>&1" RDWR] >> set mainPipe [open "|/bin/sh" RDWR] >> fconfigure $mainPipe -buffering line -blocking 0 >> >> # Open the console: >> console::open "*R console*" >> console::strict::turnOn "*R console*" -readlineProc R::sendthis >> puts $mainPipe "R --vanilla --no-readline --interactive 2>&1" >> >> # Set up a handler for the output: >> fileevent $mainPipe readable [list R::receiveAndDisplay $mainPipe] >> } >> >> # The error pipe error messages from R. >> # The prompt is sent over stdout. >> >> >> # Stopper: >> proc R::stop { } { >> # Close the pipe: >> variable mainPipe >> catch {close $mainPipe} >> # And close the console window: >> } >> >> # Event handler for both R::mainPipe: >> proc R::receiveAndDisplay { pipe } { >> if { [eof $pipe] } { >> # There is nothing more to read --- just stop: >> variable done 1 >> stop >> return >> } >> set res [read $pipe] >> variable cmd >> # Insert the result in the window: >> console::strict::write "*R console*" "$res" >> variable done 1 >> >> variable error >> if { [regexp -- {(?:Syntax error|User error|Error):.*} $res error] } { >> variable exitcode 1 >> } else { >> variable exitcode 0 >> } >> } >> >> >> proc R::sendthis { win str prompt } { >> variable mainPipe >> variable cmd $str >> puts $mainPipe $cmd >> # Timeout mechanisms: We are going to wait for the variable $done. >> # Make sure it is written at least ofter some time: >> set timeout [after 10000 {set ::R::done "TIMEOUT"}] >> vwait ::R::done >> # If we have come so far there is no more need for the time bomb: >> after cancel $timeout >> variable done >> if { [string equal $done "TIMEOUT"] } { >> stop >> error "TIMEOUT" >> } >> } >> >> >> # This proc sends a command to the console, i.e. just writes it in the >> # console window at [maxPos]. It may accept an argument, but is mostly >> # used without, then it just takes the current input region. >> # >> # And then press the trigger for sending >> # to the process (this is handled by console::strict::RETURN and >> # ultimately by R::sendThis, since this proc was declared as readlineProc >> # when setting up the strictness. >> proc R::send {} { >> if { ![isSelection] } { >> selection set {*}[findEnclosingStatement] >> after 100 >> } >> set next [selEnd] >> set cmd [selection get] >> # set cmd [stripComments $cmd] >> set cmd [string trim $cmd] >> >> if { [catch {sendAndExecute $cmd} err] } { >> status::msg $err >> } else { >> after 150 >> if { [catch {nextRegion $next}] } { >> goto $next >> if { [pos::compare $next != [linePos start $next]] } { >> # This is at file end without a new line to write on. >> text insert \n >> } >> } >> } >> return "" >> } >> >> >> proc R::sendAndExecute { cmd } { >> if { ![isRunning] } { >> set win [win::Current] >> start >> bringToFront $win >> } >> goto -w "*R console*" [maxPos -w "*R console*"] >> foreach line [split $cmd \r\n] { >> text insert -w "*R console*" "$line" >> console::strict::RETURN "*R console*" >> } >> variable exitcode >> if { $exitcode } { >> # There was an error >> variable error >> error $error >> } >> } >> >> ######## Set up the step functionality ######## >> >> >> # This proc tries to select the enclosing complete R statement, >> # except if the given position is on a blank line, in which case >> # it will look for the following complete R statement. >> proc R::findEnclosingStatement { {pos ""} {mpos ""}} { >> if { $pos eq "" } { >> set pos [getPos] >> } >> if { $mpos eq "" } { >> set mpos [minPos] >> } >> # The basic algorithm is to go back to look for a line which starts >> # with neither a blank nor a comment char. >> if { [catch { search -f 0 -r 1 -l $mpos {^[^\s\#]} $pos } previous] } { >> error "Cancelled. Could not find start of enclosing statement" >> } else { >> set p0 [lindex $previous 0] >> } >> # Now find the following such line start: >> if { [pos::compare $pos == $p0] } { >> set pos [pos::math $pos + 1] >> } >> >> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >> set p1 [maxPos] >> } else { >> set p1 [lindex $next 0] >> } >> # What we now have is typically too big a selection, as it will involve >> # blank lines and comments following the statement. Search backwards >> # from $p1 to find a nonwhite followed by some space and linebreak >> if { ![catch { search -f 0 -r 1 -l $p0 {^[^\#]*[^ \t\#][ \t]*$} [pos::math $p1 -1] } pre] } { >> # The search string says: look for a complete line whose last >> # nonwhite is not a \# and whose previous content does contain a \# >> >> # JK:2018: there seems to be a problem with backward search, namely that >> # the found match may extend later than the start position of the search >> if { [pos::compare [lindex $pre 1] < $p1] } { >> set p1 [pos::math [lindex $pre 1] + 1] >> } >> >> } >> >> # The selection might also be too small, though, namely if there is >> # some unbalanced parenthesis or brace >> set ok 0 >> while { !$ok } { >> set ok 1 >> set parens [search -all -n -f 1 -r 1 -l $p1 {(\{|\()} $p0] >> foreach parpar $parens { >> # CHANGED since search -all now returns a list of pairs JK:2018-11-05 >> foreach {par0 par1} $parpar {} >> set match [matchIt [lookAt $par0] $par1] >> # alertnote [lookAt [lindex $par 0]] >> if { [pos::compare $match >= $p1] } { >> set p1 [pos::math $match + 1] >> set ok 0 >> } >> } >> } >> # JK:2018: we need to include the whole line: >> if { [pos::math $p1 > [linePos start $p1]] } { >> set p1 [linePos next $p1] >> } >> return [list $p0 $p1] >> } >> >> # Select the next input region. If no next input >> # region is found, an error is raised. >> proc R::nextRegion { {pos ""} } { >> if { $pos eq "" } { >> if { [isSelection] } { >> set pos [selEnd] >> } else { >> set pos [pos::math [getPos] +1] >> } >> } >> if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { >> error "Cancelled. Could not find next statement" >> } >> selection set {*}[findEnclosingStatement [lindex $next 1]] >> # If we are too close to the bottom of the window...: >> getWinInfo -w [win::Current] a >> set bottomline [expr {$a(currline) + $a(linesdisp) - 1}] >> set thisline [lindex [posToRowCol -w [win::Current] [selEnd]] 0] >> if { [expr {$bottomline - $thisline}] < 4 } { >> centerRedraw >> } >> } >> >> # Handle the enter key in a source window. >> # (The enter key in the console is handled by the general strictshell bindtag.) >> proc R::enter {} { >> if { ![isRunning] } { >> set win [win::Current] >> start >> bringToFront $win >> nextRegion >> } else { >> send >> variable exitcode >> if { $exitcode } { >> # There was an error >> variable error >> status::msg $error >> beep >> } >> } >> } >> >> # Enter (both numeric block and iBook keyboard): >> binding create -tag S {v Enter} ::R::enter >> binding create -tag S {v 0x34} ::R::enter >> >> # Opt-ctrl-Downarrow >> binding create -tag S {ozv 0x7d} ::R::nextRegion >> binding create -tag S {ozv Down} ::R::nextRegion >> >> >> proc R::isRunning {} { >> # A better check should be performed... >> return [win::Exists "*R console*"] >> } >> >> # # Auxiliary proc, to avoid sending comments to the console. >> # proc R::stripComments { txt } { >> # set noOpeningOrClosing {(?:[^\(\*]|[\(][^\*]|[\*][^\)])*} >> # # This means: we don't accept ( or * >> # # except ( followed by anything else than * >> # # and except * followed by anything else than ) >> # append commentExpr {\(\*} ${noOpeningOrClosing} {\*+\)} >> # # Note the plus: it is necessary to match a comment ending with **) >> # set i 0 >> # while { [regsub -- $commentExpr $txt "" txt] } { >> # incr i >> # } >> # set res "" >> # foreach line [split $txt \r\n] { >> # if { ![string is space $line] } { >> # append res $line \r >> # # Note that R is happiest if it gets carriage returns. >> # # If it gets newlines, it will write a new prompt for each >> # # newline. >> # } >> # } >> # return $res >> # } >> # >> > |
From: <el...@li...> - 2021-05-13 17:35:28
|
Bernard, I do not need step through, as I debug with RStudio (which I also could not not make work, anyway) which is rare as I do only very small stuff (dabble). I just like to run the buffer/file... el — Sent from Dr Lisse’s iPhone On 13. May 2021, 19:28 +0200, Bernard Desgraupes <bde...@or...>, wrote: > Hi Joachim, > > the URL below seems to be broken. I get: > <<< The requested URL /~kock/www/tmp/R-shell-cocoa.tcl.zip was not found on this server. >>> > > Bernard > > > > Le 13 mai 2021 à 19:02, Joachim Kock <ko...@ma...> a écrit : > > > > Hi all, > > > > for some years I have been running my own little > > interface to command-line R. In addition to a plain > > R console inside Alpha, the feature is that from an > > R script file you can step through the commands with > > shift-Return, and then that command is sent to the > > console and evaluated. > > > > If you want to try it out, here it is. > > I'll be happy to help if you have questions. > > > > Cheers, > > Joachim. > > > > PS: in case the email transmission screws up the > > line breaks of the script, you can also take it from > > http://mat.uab.cat/~kock/www/tmp/R-shell-cocoa.tcl.zip > > > > > > ---- > > > > ## -*-Tcl-*- (nowrap) > > # ################################################################### > > # AlphaTcl > > # > > # created: 2011-11-18 18:23 > > # last update: 2013-01-05 18:32 > > # > > # File: "R-shell.tcl" > > # Author: Joachim Kock <ko...@ma...> > > # Description: R console (interaction with R). > > # > > ## > > > > > > # Initialise namespace: > > namespace eval R {} > > > > > > > > ######## Set up the R console functionality ######## > > > > hook::register closeHook R::properClose S > > > > console::create "*R console*" -mode S -attr 1 -histsize 50 \ > > -fontsize 12 -g [list 1021 120 697 558] > > > > proc R::properClose { win } { > > if { $win eq "*R console*" } { > > stop > > } > > } > > > > proc R::start { } { > > # We should not start a new instance, nor should we send start > > # instructions to an already running instance. So check: > > if { [R::isRunning] } { > > console::open "*R console*" > > return > > } > > > > # Otherwise we need to really start it up: > > > > # Check that R is installed: > > if { [regexp "^no R" [exec which R]] } { > > alertnote "Could not start R." "Please check your R installation." > > error "Cancel: Could not start R" > > } > > > > variable mainPipe > > variable promptPos > > > > # Unfortunately (standard problem) the following does not work: > > # set mainPipe [open "|R --vanilla --interactive 2>&1" RDWR] > > set mainPipe [open "|/bin/sh" RDWR] > > fconfigure $mainPipe -buffering line -blocking 0 > > > > # Open the console: > > console::open "*R console*" > > console::strict::turnOn "*R console*" -readlineProc R::sendthis > > puts $mainPipe "R --vanilla --no-readline --interactive 2>&1" > > > > # Set up a handler for the output: > > fileevent $mainPipe readable [list R::receiveAndDisplay $mainPipe] > > } > > > > # The error pipe error messages from R. > > # The prompt is sent over stdout. > > > > > > # Stopper: > > proc R::stop { } { > > # Close the pipe: > > variable mainPipe > > catch {close $mainPipe} > > # And close the console window: > > } > > > > # Event handler for both R::mainPipe: > > proc R::receiveAndDisplay { pipe } { > > if { [eof $pipe] } { > > # There is nothing more to read --- just stop: > > variable done 1 > > stop > > return > > } > > set res [read $pipe] > > variable cmd > > # Insert the result in the window: > > console::strict::write "*R console*" "$res" > > variable done 1 > > > > variable error > > if { [regexp -- {(?:Syntax error|User error|Error):.*} $res error] } { > > variable exitcode 1 > > } else { > > variable exitcode 0 > > } > > } > > > > > > proc R::sendthis { win str prompt } { > > variable mainPipe > > variable cmd $str > > puts $mainPipe $cmd > > # Timeout mechanisms: We are going to wait for the variable $done. > > # Make sure it is written at least ofter some time: > > set timeout [after 10000 {set ::R::done "TIMEOUT"}] > > vwait ::R::done > > # If we have come so far there is no more need for the time bomb: > > after cancel $timeout > > variable done > > if { [string equal $done "TIMEOUT"] } { > > stop > > error "TIMEOUT" > > } > > } > > > > > > # This proc sends a command to the console, i.e. just writes it in the > > # console window at [maxPos]. It may accept an argument, but is mostly > > # used without, then it just takes the current input region. > > # > > # And then press the trigger for sending > > # to the process (this is handled by console::strict::RETURN and > > # ultimately by R::sendThis, since this proc was declared as readlineProc > > # when setting up the strictness. > > proc R::send {} { > > if { ![isSelection] } { > > selection set {*}[findEnclosingStatement] > > after 100 > > } > > set next [selEnd] > > set cmd [selection get] > > # set cmd [stripComments $cmd] > > set cmd [string trim $cmd] > > > > if { [catch {sendAndExecute $cmd} err] } { > > status::msg $err > > } else { > > after 150 > > if { [catch {nextRegion $next}] } { > > goto $next > > if { [pos::compare $next != [linePos start $next]] } { > > # This is at file end without a new line to write on. > > text insert \n > > } > > } > > } > > return "" > > } > > > > > > proc R::sendAndExecute { cmd } { > > if { ![isRunning] } { > > set win [win::Current] > > start > > bringToFront $win > > } > > goto -w "*R console*" [maxPos -w "*R console*"] > > foreach line [split $cmd \r\n] { > > text insert -w "*R console*" "$line" > > console::strict::RETURN "*R console*" > > } > > variable exitcode > > if { $exitcode } { > > # There was an error > > variable error > > error $error > > } > > } > > > > ######## Set up the step functionality ######## > > > > > > # This proc tries to select the enclosing complete R statement, > > # except if the given position is on a blank line, in which case > > # it will look for the following complete R statement. > > proc R::findEnclosingStatement { {pos ""} {mpos ""}} { > > if { $pos eq "" } { > > set pos [getPos] > > } > > if { $mpos eq "" } { > > set mpos [minPos] > > } > > # The basic algorithm is to go back to look for a line which starts > > # with neither a blank nor a comment char. > > if { [catch { search -f 0 -r 1 -l $mpos {^[^\s\#]} $pos } previous] } { > > error "Cancelled. Could not find start of enclosing statement" > > } else { > > set p0 [lindex $previous 0] > > } > > # Now find the following such line start: > > if { [pos::compare $pos == $p0] } { > > set pos [pos::math $pos + 1] > > } > > > > if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { > > set p1 [maxPos] > > } else { > > set p1 [lindex $next 0] > > } > > # What we now have is typically too big a selection, as it will involve > > # blank lines and comments following the statement. Search backwards > > # from $p1 to find a nonwhite followed by some space and linebreak > > if { ![catch { search -f 0 -r 1 -l $p0 {^[^\#]*[^ \t\#][ \t]*$} [pos::math $p1 -1] } pre] } { > > # The search string says: look for a complete line whose last > > # nonwhite is not a \# and whose previous content does contain a \# > > > > # JK:2018: there seems to be a problem with backward search, namely that > > # the found match may extend later than the start position of the search > > if { [pos::compare [lindex $pre 1] < $p1] } { > > set p1 [pos::math [lindex $pre 1] + 1] > > } > > > > } > > > > # The selection might also be too small, though, namely if there is > > # some unbalanced parenthesis or brace > > set ok 0 > > while { !$ok } { > > set ok 1 > > set parens [search -all -n -f 1 -r 1 -l $p1 {(\{|\()} $p0] > > foreach parpar $parens { > > # CHANGED since search -all now returns a list of pairs JK:2018-11-05 > > foreach {par0 par1} $parpar {} > > set match [matchIt [lookAt $par0] $par1] > > # alertnote [lookAt [lindex $par 0]] > > if { [pos::compare $match >= $p1] } { > > set p1 [pos::math $match + 1] > > set ok 0 > > } > > } > > } > > # JK:2018: we need to include the whole line: > > if { [pos::math $p1 > [linePos start $p1]] } { > > set p1 [linePos next $p1] > > } > > return [list $p0 $p1] > > } > > > > # Select the next input region. If no next input > > # region is found, an error is raised. > > proc R::nextRegion { {pos ""} } { > > if { $pos eq "" } { > > if { [isSelection] } { > > set pos [selEnd] > > } else { > > set pos [pos::math [getPos] +1] > > } > > } > > if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { > > error "Cancelled. Could not find next statement" > > } > > selection set {*}[findEnclosingStatement [lindex $next 1]] > > # If we are too close to the bottom of the window...: > > getWinInfo -w [win::Current] a > > set bottomline [expr {$a(currline) + $a(linesdisp) - 1}] > > set thisline [lindex [posToRowCol -w [win::Current] [selEnd]] 0] > > if { [expr {$bottomline - $thisline}] < 4 } { > > centerRedraw > > } > > } > > > > # Handle the enter key in a source window. > > # (The enter key in the console is handled by the general strictshell bindtag.) > > proc R::enter {} { > > if { ![isRunning] } { > > set win [win::Current] > > start > > bringToFront $win > > nextRegion > > } else { > > send > > variable exitcode > > if { $exitcode } { > > # There was an error > > variable error > > status::msg $error > > beep > > } > > } > > } > > > > # Enter (both numeric block and iBook keyboard): > > binding create -tag S {v Enter} ::R::enter > > binding create -tag S {v 0x34} ::R::enter > > > > # Opt-ctrl-Downarrow > > binding create -tag S {ozv 0x7d} ::R::nextRegion > > binding create -tag S {ozv Down} ::R::nextRegion > > > > > > proc R::isRunning {} { > > # A better check should be performed... > > return [win::Exists "*R console*"] > > } > > > > # # Auxiliary proc, to avoid sending comments to the console. > > # proc R::stripComments { txt } { > > # set noOpeningOrClosing {(?:[^\(\*]|[\(][^\*]|[\*][^\)])*} > > # # This means: we don't accept ( or * > > # # except ( followed by anything else than * > > # # and except * followed by anything else than ) > > # append commentExpr {\(\*} ${noOpeningOrClosing} {\*+\)} > > # # Note the plus: it is necessary to match a comment ending with **) > > # set i 0 > > # while { [regsub -- $commentExpr $txt "" txt] } { > > # incr i > > # } > > # set res "" > > # foreach line [split $txt \r\n] { > > # if { ![string is space $line] } { > > # append res $line \r > > # # Note that R is happiest if it gets carriage returns. > > # # If it gets newlines, it will write a new prompt for each > > # # newline. > > # } > > # } > > # return $res > > # } > > # > > > > > > _______________________________________________ > AlphaCocoa-devel mailing list > Alp...@li... > https://lists.sourceforge.net/lists/listinfo/alphacocoa-devel |
From: Bernard D. <bde...@or...> - 2021-05-13 17:28:06
|
Hi Joachim, the URL below seems to be broken. I get: <<< The requested URL /~kock/www/tmp/R-shell-cocoa.tcl.zip was not found on this server. >>> Bernard > Le 13 mai 2021 à 19:02, Joachim Kock <ko...@ma...> a écrit : > > Hi all, > > for some years I have been running my own little > interface to command-line R. In addition to a plain > R console inside Alpha, the feature is that from an > R script file you can step through the commands with > shift-Return, and then that command is sent to the > console and evaluated. > > If you want to try it out, here it is. > I'll be happy to help if you have questions. > > Cheers, > Joachim. > > PS: in case the email transmission screws up the > line breaks of the script, you can also take it from > http://mat.uab.cat/~kock/www/tmp/R-shell-cocoa.tcl.zip > > > ---- > > ## -*-Tcl-*- (nowrap) > # ################################################################### > # AlphaTcl > # > # created: 2011-11-18 18:23 > # last update: 2013-01-05 18:32 > # > # File: "R-shell.tcl" > # Author: Joachim Kock <ko...@ma...> > # Description: R console (interaction with R). > # > ## > > > # Initialise namespace: > namespace eval R {} > > > > ######## Set up the R console functionality ######## > > hook::register closeHook R::properClose S > > console::create "*R console*" -mode S -attr 1 -histsize 50 \ > -fontsize 12 -g [list 1021 120 697 558] > > proc R::properClose { win } { > if { $win eq "*R console*" } { > stop > } > } > > proc R::start { } { > # We should not start a new instance, nor should we send start > # instructions to an already running instance. So check: > if { [R::isRunning] } { > console::open "*R console*" > return > } > > # Otherwise we need to really start it up: > > # Check that R is installed: > if { [regexp "^no R" [exec which R]] } { > alertnote "Could not start R." "Please check your R installation." > error "Cancel: Could not start R" > } > > variable mainPipe > variable promptPos > > # Unfortunately (standard problem) the following does not work: > # set mainPipe [open "|R --vanilla --interactive 2>&1" RDWR] > set mainPipe [open "|/bin/sh" RDWR] > fconfigure $mainPipe -buffering line -blocking 0 > > # Open the console: > console::open "*R console*" > console::strict::turnOn "*R console*" -readlineProc R::sendthis > puts $mainPipe "R --vanilla --no-readline --interactive 2>&1" > > # Set up a handler for the output: > fileevent $mainPipe readable [list R::receiveAndDisplay $mainPipe] > } > > # The error pipe error messages from R. > # The prompt is sent over stdout. > > > # Stopper: > proc R::stop { } { > # Close the pipe: > variable mainPipe > catch {close $mainPipe} > # And close the console window: > } > > # Event handler for both R::mainPipe: > proc R::receiveAndDisplay { pipe } { > if { [eof $pipe] } { > # There is nothing more to read --- just stop: > variable done 1 > stop > return > } > set res [read $pipe] > variable cmd > # Insert the result in the window: > console::strict::write "*R console*" "$res" > variable done 1 > > variable error > if { [regexp -- {(?:Syntax error|User error|Error):.*} $res error] } { > variable exitcode 1 > } else { > variable exitcode 0 > } > } > > > proc R::sendthis { win str prompt } { > variable mainPipe > variable cmd $str > puts $mainPipe $cmd > # Timeout mechanisms: We are going to wait for the variable $done. > # Make sure it is written at least ofter some time: > set timeout [after 10000 {set ::R::done "TIMEOUT"}] > vwait ::R::done > # If we have come so far there is no more need for the time bomb: > after cancel $timeout > variable done > if { [string equal $done "TIMEOUT"] } { > stop > error "TIMEOUT" > } > } > > > # This proc sends a command to the console, i.e. just writes it in the > # console window at [maxPos]. It may accept an argument, but is mostly > # used without, then it just takes the current input region. > # > # And then press the trigger for sending > # to the process (this is handled by console::strict::RETURN and > # ultimately by R::sendThis, since this proc was declared as readlineProc > # when setting up the strictness. > proc R::send {} { > if { ![isSelection] } { > selection set {*}[findEnclosingStatement] > after 100 > } > set next [selEnd] > set cmd [selection get] > # set cmd [stripComments $cmd] > set cmd [string trim $cmd] > > if { [catch {sendAndExecute $cmd} err] } { > status::msg $err > } else { > after 150 > if { [catch {nextRegion $next}] } { > goto $next > if { [pos::compare $next != [linePos start $next]] } { > # This is at file end without a new line to write on. > text insert \n > } > } > } > return "" > } > > > proc R::sendAndExecute { cmd } { > if { ![isRunning] } { > set win [win::Current] > start > bringToFront $win > } > goto -w "*R console*" [maxPos -w "*R console*"] > foreach line [split $cmd \r\n] { > text insert -w "*R console*" "$line" > console::strict::RETURN "*R console*" > } > variable exitcode > if { $exitcode } { > # There was an error > variable error > error $error > } > } > > ######## Set up the step functionality ######## > > > # This proc tries to select the enclosing complete R statement, > # except if the given position is on a blank line, in which case > # it will look for the following complete R statement. > proc R::findEnclosingStatement { {pos ""} {mpos ""}} { > if { $pos eq "" } { > set pos [getPos] > } > if { $mpos eq "" } { > set mpos [minPos] > } > # The basic algorithm is to go back to look for a line which starts > # with neither a blank nor a comment char. > if { [catch { search -f 0 -r 1 -l $mpos {^[^\s\#]} $pos } previous] } { > error "Cancelled. Could not find start of enclosing statement" > } else { > set p0 [lindex $previous 0] > } > # Now find the following such line start: > if { [pos::compare $pos == $p0] } { > set pos [pos::math $pos + 1] > } > > if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { > set p1 [maxPos] > } else { > set p1 [lindex $next 0] > } > # What we now have is typically too big a selection, as it will involve > # blank lines and comments following the statement. Search backwards > # from $p1 to find a nonwhite followed by some space and linebreak > if { ![catch { search -f 0 -r 1 -l $p0 {^[^\#]*[^ \t\#][ \t]*$} [pos::math $p1 -1] } pre] } { > # The search string says: look for a complete line whose last > # nonwhite is not a \# and whose previous content does contain a \# > > # JK:2018: there seems to be a problem with backward search, namely that > # the found match may extend later than the start position of the search > if { [pos::compare [lindex $pre 1] < $p1] } { > set p1 [pos::math [lindex $pre 1] + 1] > } > > } > > # The selection might also be too small, though, namely if there is > # some unbalanced parenthesis or brace > set ok 0 > while { !$ok } { > set ok 1 > set parens [search -all -n -f 1 -r 1 -l $p1 {(\{|\()} $p0] > foreach parpar $parens { > # CHANGED since search -all now returns a list of pairs JK:2018-11-05 > foreach {par0 par1} $parpar {} > set match [matchIt [lookAt $par0] $par1] > # alertnote [lookAt [lindex $par 0]] > if { [pos::compare $match >= $p1] } { > set p1 [pos::math $match + 1] > set ok 0 > } > } > } > # JK:2018: we need to include the whole line: > if { [pos::math $p1 > [linePos start $p1]] } { > set p1 [linePos next $p1] > } > return [list $p0 $p1] > } > > # Select the next input region. If no next input > # region is found, an error is raised. > proc R::nextRegion { {pos ""} } { > if { $pos eq "" } { > if { [isSelection] } { > set pos [selEnd] > } else { > set pos [pos::math [getPos] +1] > } > } > if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { > error "Cancelled. Could not find next statement" > } > selection set {*}[findEnclosingStatement [lindex $next 1]] > # If we are too close to the bottom of the window...: > getWinInfo -w [win::Current] a > set bottomline [expr {$a(currline) + $a(linesdisp) - 1}] > set thisline [lindex [posToRowCol -w [win::Current] [selEnd]] 0] > if { [expr {$bottomline - $thisline}] < 4 } { > centerRedraw > } > } > > # Handle the enter key in a source window. > # (The enter key in the console is handled by the general strictshell bindtag.) > proc R::enter {} { > if { ![isRunning] } { > set win [win::Current] > start > bringToFront $win > nextRegion > } else { > send > variable exitcode > if { $exitcode } { > # There was an error > variable error > status::msg $error > beep > } > } > } > > # Enter (both numeric block and iBook keyboard): > binding create -tag S {v Enter} ::R::enter > binding create -tag S {v 0x34} ::R::enter > > # Opt-ctrl-Downarrow > binding create -tag S {ozv 0x7d} ::R::nextRegion > binding create -tag S {ozv Down} ::R::nextRegion > > > proc R::isRunning {} { > # A better check should be performed... > return [win::Exists "*R console*"] > } > > # # Auxiliary proc, to avoid sending comments to the console. > # proc R::stripComments { txt } { > # set noOpeningOrClosing {(?:[^\(\*]|[\(][^\*]|[\*][^\)])*} > # # This means: we don't accept ( or * > # # except ( followed by anything else than * > # # and except * followed by anything else than ) > # append commentExpr {\(\*} ${noOpeningOrClosing} {\*+\)} > # # Note the plus: it is necessary to match a comment ending with **) > # set i 0 > # while { [regsub -- $commentExpr $txt "" txt] } { > # incr i > # } > # set res "" > # foreach line [split $txt \r\n] { > # if { ![string is space $line] } { > # append res $line \r > # # Note that R is happiest if it gets carriage returns. > # # If it gets newlines, it will write a new prompt for each > # # newline. > # } > # } > # return $res > # } > # > |
From: Dr E. W L. <el...@li...> - 2021-05-13 17:08:46
|
Bernard TextMate2 opens (on CMD-R) another window (R TextMate Runtime) and (probably) executes a source("filename.R", echo=TRUE) the output of which shows up in the Runtime window. I haven't tried doing it on R Code in an unnamed buffer but would assume that it would ask me to save it into a file and then does the above :-)-O. Something similar for an unsaved buffer/file ((Ask to) Save first, then run R) That would most certainly do it for me :-)-O greetings, el On 2021-05-13 16:34 , Bernard Desgraupes wrote: > Hi Eberhard, > > the commands « Process Current File » and « Process Selection » in > Alpha’s R menu are meant to work with the GUI versions of R (either > R.app or RStudio). Communication goes through AppleEvents. So the > services in Helper Apps expect you to choose one of these > applications. > > The R command line does not understand Apple Events. What you want to > achieve is certainly feasible and could be implemented using Tcl’s > exec command. > > But how (or where) would you expect the output of R’s calculations to > be sent back ? > > Cheers, > Bernard [...] -- Dr. Eberhard W. Lisse \ / Obstetrician & Gynaecologist el...@li... / * | Telephone: +264 81 124 6733 (cell) PO Box 8421 Bachbrecht \ / If this email is signed with GPG/PGP 10007, Namibia ;____/ Sect 20 of Act No. 4 of 2019 may apply |
From: Joachim K. <ko...@ma...> - 2021-05-13 17:02:39
|
Hi all, for some years I have been running my own little interface to command-line R. In addition to a plain R console inside Alpha, the feature is that from an R script file you can step through the commands with shift-Return, and then that command is sent to the console and evaluated. If you want to try it out, here it is. I'll be happy to help if you have questions. Cheers, Joachim. PS: in case the email transmission screws up the line breaks of the script, you can also take it from http://mat.uab.cat/~kock/www/tmp/R-shell-cocoa.tcl.zip ---- ## -*-Tcl-*- (nowrap) # ################################################################### # AlphaTcl # # created: 2011-11-18 18:23 # last update: 2013-01-05 18:32 # # File: "R-shell.tcl" # Author: Joachim Kock <ko...@ma...> # Description: R console (interaction with R). # ## # Initialise namespace: namespace eval R {} ######## Set up the R console functionality ######## hook::register closeHook R::properClose S console::create "*R console*" -mode S -attr 1 -histsize 50 \ -fontsize 12 -g [list 1021 120 697 558] proc R::properClose { win } { if { $win eq "*R console*" } { stop } } proc R::start { } { # We should not start a new instance, nor should we send start # instructions to an already running instance. So check: if { [R::isRunning] } { console::open "*R console*" return } # Otherwise we need to really start it up: # Check that R is installed: if { [regexp "^no R" [exec which R]] } { alertnote "Could not start R." "Please check your R installation." error "Cancel: Could not start R" } variable mainPipe variable promptPos # Unfortunately (standard problem) the following does not work: # set mainPipe [open "|R --vanilla --interactive 2>&1" RDWR] set mainPipe [open "|/bin/sh" RDWR] fconfigure $mainPipe -buffering line -blocking 0 # Open the console: console::open "*R console*" console::strict::turnOn "*R console*" -readlineProc R::sendthis puts $mainPipe "R --vanilla --no-readline --interactive 2>&1" # Set up a handler for the output: fileevent $mainPipe readable [list R::receiveAndDisplay $mainPipe] } # The error pipe error messages from R. # The prompt is sent over stdout. # Stopper: proc R::stop { } { # Close the pipe: variable mainPipe catch {close $mainPipe} # And close the console window: } # Event handler for both R::mainPipe: proc R::receiveAndDisplay { pipe } { if { [eof $pipe] } { # There is nothing more to read --- just stop: variable done 1 stop return } set res [read $pipe] variable cmd # Insert the result in the window: console::strict::write "*R console*" "$res" variable done 1 variable error if { [regexp -- {(?:Syntax error|User error|Error):.*} $res error] } { variable exitcode 1 } else { variable exitcode 0 } } proc R::sendthis { win str prompt } { variable mainPipe variable cmd $str puts $mainPipe $cmd # Timeout mechanisms: We are going to wait for the variable $done. # Make sure it is written at least ofter some time: set timeout [after 10000 {set ::R::done "TIMEOUT"}] vwait ::R::done # If we have come so far there is no more need for the time bomb: after cancel $timeout variable done if { [string equal $done "TIMEOUT"] } { stop error "TIMEOUT" } } # This proc sends a command to the console, i.e. just writes it in the # console window at [maxPos]. It may accept an argument, but is mostly # used without, then it just takes the current input region. # # And then press the trigger for sending # to the process (this is handled by console::strict::RETURN and # ultimately by R::sendThis, since this proc was declared as readlineProc # when setting up the strictness. proc R::send {} { if { ![isSelection] } { selection set {*}[findEnclosingStatement] after 100 } set next [selEnd] set cmd [selection get] # set cmd [stripComments $cmd] set cmd [string trim $cmd] if { [catch {sendAndExecute $cmd} err] } { status::msg $err } else { after 150 if { [catch {nextRegion $next}] } { goto $next if { [pos::compare $next != [linePos start $next]] } { # This is at file end without a new line to write on. text insert \n } } } return "" } proc R::sendAndExecute { cmd } { if { ![isRunning] } { set win [win::Current] start bringToFront $win } goto -w "*R console*" [maxPos -w "*R console*"] foreach line [split $cmd \r\n] { text insert -w "*R console*" "$line" console::strict::RETURN "*R console*" } variable exitcode if { $exitcode } { # There was an error variable error error $error } } ######## Set up the step functionality ######## # This proc tries to select the enclosing complete R statement, # except if the given position is on a blank line, in which case # it will look for the following complete R statement. proc R::findEnclosingStatement { {pos ""} {mpos ""}} { if { $pos eq "" } { set pos [getPos] } if { $mpos eq "" } { set mpos [minPos] } # The basic algorithm is to go back to look for a line which starts # with neither a blank nor a comment char. if { [catch { search -f 0 -r 1 -l $mpos {^[^\s\#]} $pos } previous] } { error "Cancelled. Could not find start of enclosing statement" } else { set p0 [lindex $previous 0] } # Now find the following such line start: if { [pos::compare $pos == $p0] } { set pos [pos::math $pos + 1] } if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { set p1 [maxPos] } else { set p1 [lindex $next 0] } # What we now have is typically too big a selection, as it will involve # blank lines and comments following the statement. Search backwards # from $p1 to find a nonwhite followed by some space and linebreak if { ![catch { search -f 0 -r 1 -l $p0 {^[^\#]*[^ \t\#][ \t]*$} [pos::math $p1 -1] } pre] } { # The search string says: look for a complete line whose last # nonwhite is not a \# and whose previous content does contain a \# # JK:2018: there seems to be a problem with backward search, namely that # the found match may extend later than the start position of the search if { [pos::compare [lindex $pre 1] < $p1] } { set p1 [pos::math [lindex $pre 1] + 1] } } # The selection might also be too small, though, namely if there is # some unbalanced parenthesis or brace set ok 0 while { !$ok } { set ok 1 set parens [search -all -n -f 1 -r 1 -l $p1 {(\{|\()} $p0] foreach parpar $parens { # CHANGED since search -all now returns a list of pairs JK:2018-11-05 foreach {par0 par1} $parpar {} set match [matchIt [lookAt $par0] $par1] # alertnote [lookAt [lindex $par 0]] if { [pos::compare $match >= $p1] } { set p1 [pos::math $match + 1] set ok 0 } } } # JK:2018: we need to include the whole line: if { [pos::math $p1 > [linePos start $p1]] } { set p1 [linePos next $p1] } return [list $p0 $p1] } # Select the next input region. If no next input # region is found, an error is raised. proc R::nextRegion { {pos ""} } { if { $pos eq "" } { if { [isSelection] } { set pos [selEnd] } else { set pos [pos::math [getPos] +1] } } if { [catch { search -f 1 -r 1 {^[^\s\#]} $pos } next] } { error "Cancelled. Could not find next statement" } selection set {*}[findEnclosingStatement [lindex $next 1]] # If we are too close to the bottom of the window...: getWinInfo -w [win::Current] a set bottomline [expr {$a(currline) + $a(linesdisp) - 1}] set thisline [lindex [posToRowCol -w [win::Current] [selEnd]] 0] if { [expr {$bottomline - $thisline}] < 4 } { centerRedraw } } # Handle the enter key in a source window. # (The enter key in the console is handled by the general strictshell bindtag.) proc R::enter {} { if { ![isRunning] } { set win [win::Current] start bringToFront $win nextRegion } else { send variable exitcode if { $exitcode } { # There was an error variable error status::msg $error beep } } } # Enter (both numeric block and iBook keyboard): binding create -tag S {v Enter} ::R::enter binding create -tag S {v 0x34} ::R::enter # Opt-ctrl-Downarrow binding create -tag S {ozv 0x7d} ::R::nextRegion binding create -tag S {ozv Down} ::R::nextRegion proc R::isRunning {} { # A better check should be performed... return [win::Exists "*R console*"] } # # Auxiliary proc, to avoid sending comments to the console. # proc R::stripComments { txt } { # set noOpeningOrClosing {(?:[^\(\*]|[\(][^\*]|[\*][^\)])*} # # This means: we don't accept ( or * # # except ( followed by anything else than * # # and except * followed by anything else than ) # append commentExpr {\(\*} ${noOpeningOrClosing} {\*+\)} # # Note the plus: it is necessary to match a comment ending with **) # set i 0 # while { [regsub -- $commentExpr $txt "" txt] } { # incr i # } # set res "" # foreach line [split $txt \r\n] { # if { ![string is space $line] } { # append res $line \r # # Note that R is happiest if it gets carriage returns. # # If it gets newlines, it will write a new prompt for each # # newline. # } # } # return $res # } # |