From 0438a7cc5e45c95a22e8c0e805197e0a9b024bce Mon Sep 17 00:00:00 2001 From: Steven Phillips Date: Tue, 10 Sep 2024 09:11:59 +0100 Subject: [PATCH] Added github script, fixed msi to not be in zip, changed unix default user-path to be .config/jasspa --- .github/workflows/build-windows.yml | 2 +- microemacs/contribs/github.emf | 247 ++++++++++++++++++++++++++++ microemacs/doc/cygwin.txt | 8 +- microemacs/doc/m2nar001.2 | 36 ++-- microemacs/doc/m2nar003.2 | 2 +- microemacs/doc/m5var089.5 | 19 +-- microemacs/doc/m5var090.5 | 30 ++-- microemacs/doc/me.nrs | 10 +- microemacs/macros/newuser.emf | 143 ++++++++-------- microemacs/macros/newuser.erf | 1 - microemacs/release_readme.md | 6 +- microemacs/src/dosterm.c | 10 +- microemacs/src/eextrn.h | 2 +- microemacs/src/file.c | 69 ++++---- microemacs/src/readme.txt | 32 ++-- microemacs/src/unixterm.c | 29 ++-- microemacs/src/winterm.c | 13 +- 17 files changed, 449 insertions(+), 210 deletions(-) create mode 100644 microemacs/contribs/github.emf diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 251661d7c..c4ac48f99 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -117,7 +117,7 @@ jobs: heat dir macros -o jmeMacros.wxs -scom -frag -srd -sreg -gg -cg MacrosGroupId -dr jmeMacrosDirRef candle -ext WixUIExtension -ext WixUtilExtension jme.wxs jmeMacros.wxs light -ext WixUIExtension -ext WixUtilExtension -o Jasspa_MicroEmacs_${env:MEVER}_installer_windows.msi -loc jme.wxl jme.wixobj jmeMacros.wixobj -b macros - Compress-Archive -Path Jasspa_MicroEmacs_${env:MEVER}_installer_windows.msi -DestinationPath ..\..\downloads\Jasspa_MicroEmacs_${env:MEVER}_installer_windows + Copy-Item -Path Jasspa_MicroEmacs_${env:MEVER}_installer_windows.msi -Destination ..\..\downloads - name: Compile windows100 static mec shell: pwsh diff --git a/microemacs/contribs/github.emf b/microemacs/contribs/github.emf new file mode 100644 index 000000000..27c29d324 --- /dev/null +++ b/microemacs/contribs/github.emf @@ -0,0 +1,247 @@ +; -!- emf -!- +; This is part of the JASSPA MicroEmacs macro files +; Copyright (C) 2023-2024 JASSPA (www.jasspa.com) +; See the file me.emf for copying and conditions. +; +; Authors: Steven Phillips +; Created: 2024-07-27 22:37:41 +; Synopsis: Macros used to build and create relesae +; +; Variables: +; .git.hub-tkn Github API access token +; .git.hub-url Main api url for the repository +; .git.hub-bal Build action list (Run-ID of first is passed to rest as input refToHelpAsset) +; .git.hub-brn Build reference name (typically main branch name of repository) +; .git.hub-rtp Release tag prefix +; .git.hub-rnp Release name prefix +; .git.hub-rrt Release readme template file, should point to an md ( is replaced with the version string) +; .git.hub-hdr Githup api header (uses .git.hub-tkn) +; +set-variable .git.hub-url "https://api.github.com/repos/bjasspa/jasspa/" +set-variable .git.hub-bal "|build-linux.yml|build-windows.yml|build-macos-intel.yml|build-macos-apple.yml|build-spelling.yml|" +set-variable .git.hub-brn "main" +set-variable .git.hub-rtp "me_" +set-variable .git.hub-rnp "Jasspa MicroEmacs " +set-variable .git.hub-rrt "~/jasspa/microemacs/release_readme.md" +set-variable .git.hub-hdr &spr "Accept: application/vnd.github+json\r\nAuthorization: Bearer %s\r\nX-GitHub-Api-Version: 2022-11-28\r\nUser-Agent: Jasspa" .git.hub-tkn + +set-variable %http-flags "scvwdh" +!iif ¬ &exi json-parse execute-file "hkjson" +; time used by github filter is UTC so take 12 hours off to ensure local time - 12hours gives Github start date or day before +set-variable $time -43200 +set-variable .git.hub-date &spr "%s-%02d-%02d" &lef $time 4 &mid $time 7 2 &mid $time 9 2 +set-variable $time 0 +0 define-macro github-api-call + set-variable #l1 @1 + !force set-variable #l2 @2 + !if &and $status &len #l2 + set-variable %http-header &spr ":%s:%s" #l2 .git.hub-hdr + !else + set-variable %http-header .git.hub-hdr + !endif + !force set-variable #l2 @3 + !iif &and $status &len #l2 set-variable %http-post-data #l2 + !force delete-buffer "*ghac*" + find-buffer "*ghac*" + insert-file &cat .git.hub-url #l1 + set-variable #l0 $result + beginning-of-buffer + !iif &gre #l0 399 -8 ml-write &spr "[Github %d Error: %s]" #l0 @wl +!emacro + +0 define-macro github-api-json + set-variable #l1 @1 + !force set-variable #l2 @2 + !if &and $status &len #l2 + set-variable %http-header &spr ":%s:%s" #l2 .git.hub-hdr + !else + set-variable %http-header .git.hub-hdr + !endif + !force set-variable #l2 @3 + !if &and $status &len #l2 + set-variable %http-post-data #l2 + !elif ¬ &exi %http-post-file + !elif &seq "" %http-post-file + !elif ¬ &sin "Content-Type:" %http-header + set-variable %http-header &cat %http-header "\r\nContent-Type: application/octet-stream" + !endif + !force delete-buffer "*ghaj*" + find-buffer "*ghaj*" + insert-file &cat .git.hub-url #l1 + set-variable #l0 $result + beginning-of-buffer + !iif &gre #l0 399 -8 ml-write &spr "[Github %d Error: %s]" #l0 @wl + json-parse "/json/ghaj" +!emacro + +; Build an action with given commit +; @1 - Commit SHA1 +; @2 - Name of action to build +; @3 - Full path to the artifact directory +; @4 - Additional inputs to the dispatch call +; Returns +; #p9 - Run ID +define-macro github-build-action + set-variable #l9 @1 + set-variable #l0 @2 + set-variable #l8 @3 + set-variable #l3 @4 + set-variable #l1 &cat "actions/workflows/" #l0 + github-api-call &cat #l1 "/dispatches" "" &spr "{\"ref\":\"%s\",\"inputs\":{\"refToBuild\":\"%s\"%s}}" .git.hub-brn #l9 #l3 + 30000 ml-write &spr "[Action %s dispatched... ]" #l0 + ml-write &spr "[Action %s dispatched... Getting ID]" #l0 + github-api-json &spr "%s/runs?created=%%3e%%3d%s&head_sha=%s" #l1 &rep .git.hub-date "-" "%2d" #l9 + !iif &or ¬ &seq "#" &lef &set #l2 ® "/json/ghaj/total_count" "" 1 &les &rig #l2 1 1 -8 ml-write &spr "[Github %s Error: Unexpected total_count %s]" #l0 #l2 + !iif &or ¬ &seq "#" &lef &set #l2 ® "/json/ghaj/workflow_runs/0/id" "" 1 &les &set #l5 &rig #l2 1 1 -8 ml-write &spr "[Github %s Error: Unexpected run id %s]" #l0 #l2 + set-variable #p9 #l5 + 10000 ml-write &spr "[Action %s run %s state %s... ]" #l0 #l5 &rig ® "/json/ghaj/workflow_runs/0/status" "#" 1 + set-variable #l2 0 + !repeat + github-api-json &cat "actions/runs/" #l5 + !iif &seq "" &set #l3 &rig ® "/json/ghaj/status" "" 1 -8 ml-write &spr "[Github %s Error: No run id %s status]" #l0 #l5 + !iif ¬ &lfin "|in_progress|queued|requested|waiting|pending|" #l3 !break + 10000 ml-write &spr "[Action %s run %s state %s... %d]" #l0 #l5 #l3 &inc #l2 1 + !done + !iif ¬ &seq "completed" #l3 -8 ml-write &spr "[Github %s Error: Unexpected state %s for run id %s]" #l0 #l3 #l5 + github-api-json &spr "actions/runs/%s/artifacts" #l5 + !iif &or ¬ &seq "[" &lef &set #l2 ® "/json/ghaj/artifacts" "" 1 &seq &set #l6 &rig #l2 1 "" -8 ml-write &spr "[Github %s Error: Unexpected artifacts array: %s]" #l0 #l2 + set-variable #l3 0 + !while &gre #l6 #l3 + !iif ¬ &seq &lef &set #l2 &rig ® &spr "/json/ghaj/artifacts/%d/archive_download_url" #l3 "" 1 &len .git.hub-url .git.hub-url -8 ml-write &spr "[Github %s Error: Unexpected artifact %d download URL: %s]" #l0 #l3 #l2 + set-variable #l4 &spr "%s.%s" &rig ® &spr "/json/ghaj/artifacts/%d/name" #l3 &cat #l5 #l3 1 &rig #l2 &rsin "/" #l2 + ml-write &spr "[Github %s: Downloading artifact %d to %s]" #l0 #l3 #l4 + set-variable %http-header .git.hub-hdr + !force find-file #l2 + !iif ¬ &seq "http" &lef &set #l2 $result 4 -8 ml-write &spr "[Github %s Error: Expected redirect downloading artifact - %s]" #l0 #l2 + !force delete-buffer $buffer-bname + set-variable %http-header "" + 0x80 file-op #l2 &spr "%sartifacts/%s" #l8 #l4 + !if &sin "downloads.zip" #l4 + 1 shell-command &spr "unzip \"%sartifacts/%s\" -d \"%sdownloads/\"" #l8 #l4 #l8 + !iif &set #l2 $result -8 ml-write &spr "[Github %s Error: Failed to extract downloads artifact %d zip - %s]" #l0 #l3 #l4 + !elif &sin "packages.zip" #l4 + 1 shell-command &spr "unzip \"%sartifacts/%s\" -d \"%spackages/\"" #l8 #l4 #l8 + !iif &set #l2 $result -8 ml-write &spr "[Github %s Error: Failed to extract packages artifact %d zip - %s]" #l0 #l3 #l4 + !endif + set-variable #l3 &add #l3 1 + !done +!emacro + +; Build all actions listed in .git.hub-bal with given commit +; @1 - Commit SHA1, if not given or "" then latest commit on .git.hub-brn is built +; @2 - Artifact download directory name, if not given or "" then $temp-name is used, otherwise ~/@2 is used +; Returns +; #p8 - SHA1 of the commit built +; #p9 - Full path to the artifact directory +define-macro github-build + ; Get the sha of the commit to be used for building and release + ; this can be passed in or, if not given we get the latest commit on the main branch + !force set-variable #l0 @1 + !if &or ¬ $status &seq #l0 "" + github-api-json &cat "commits/" .git.hub-brn + !iif ¬ &xseq &set #l0 &rig ® &spr "/json/ghaj/sha" "" 1 "\\h+" -8 ml-write &spr "[Github Error: Failed to get latest commit sha - %s]" #l0 + !endif + set-variable #p8 #l0 + !force set-variable #l9 @2 + !if &or ¬ $status &seq #l1 "" + set-variable #l1 $temp-name + !else + set-variable #l1 &stat a &cat "~/" #l9 + !endif + !iif ¬ &seq "X" &stat t #l1 -8 ml-write &spr "[Github Error: Output directory already exists - %s]" #l1 + !force 0x100 file-op #l1 + !iif ¬ &seq "D" &stat t #l1 -8 ml-write &spr "[Github Error: Failed to create output directory - %s]" #l1 + set-variable #l1 &cat #l1 "/" + set-variable #p9 #l1 + !force 0x100 file-op &cat #l1 "artifacts" + !force 0x100 file-op &cat #l1 "downloads" + !force 0x100 file-op &cat #l1 "packages" + ml-write &spr "[Github Build: Output to %s]" #l1 + set-variable #l4 "" + set-variable #l2 0 + !while ¬ &seq "" &set #l3 &lget .git.hub-bal &inc #l2 1 + github-build-action #l0 #l3 #l1 #l4 + !iif &seq #l4 "" set-variable #l4 &spr ",\"refToHelpAsset\":\"%s\"" #l9 + !done + ml-write &spr "[Github Build: Complete, output to %s]" #l1 +!emacro + +; Create release and upload 'download' artifacts as assets +; @1 - SHA1 of the commit built +; @2 - Release version, used with .git.hub-rtp to create tag and .git.hub-rnp to create name +; @3 - Full path to the artifact directory +; @4 - Release readme template md filename +define-macro github-release + set-variable #l0 @1 + set-variable #l9 @2 + set-variable #l1 @3 + !iif ¬ &seq "D" &stat t #l1 -8 ml-write &spr "[Github Release Error: Failed to locate given release directory - %s]" #l1 + !iif ¬ &seq "D" &stat t &cat #l1 "downloads" -8 ml-write &spr "[Github Release Error: Failed to locate given release downloads directory - %sdownloads]" #l1 + github-api-json "releases" "" &spr "{\"tag_name\":\"%s%s\",\"target_commitish\":\"%s\",\"name\":\"%s%s\",\"generate_release_notes\":false,\"draft\":true,\"prerelease\":true}" .git.hub-rtp #l9 #l0 .git.hub-rnp #l9 + !iif ¬ &xseq &set #l8 &rig ® &spr "/json/ghaj/id" "" 1 "\\h+" -8 ml-write &spr "[Github Release Error: Unexpected release ID - %s]" #l8 + !iif ¬ &seq "\"http" &lef &set #l2 ® "/json/ghaj/upload_url" "" 5 -8 ml-write &spr "[Github Release Error: Unexpected upload_url %s]" #l2 + set-variable #p7 #l8 + set-variable #l2 &rep &rig #l2 1 "{?name,label}" "?name=" + !force delete-buffer "*ghrt*" + !force delete-buffer "*ghrc*" + find-buffer "*ghrc*" + !force delete-buffer "*ghru*" + find-buffer "*ghru*" + set-variable $file-names &cat #l1 "downloads/.*\\.\\(zip\\|msi\\)" + set-variable #l1 $result + set-variable #l5 0 + !while ¬ &seq "" &set #l3 $file-names + ml-write &spr "[Github Release: Uploading asset %s]" #l3 + !if ¬ #l5 + !iif ¬ &set #l4 &sin #l9 #l3 -8 ml-write &spr "[Github Release Error: Asset %s does not have release ID %s in name]" #l3 #l9 + set-variable #l6 &lef #l3 &sub #l4 1 + !endif + find-buffer "*ghrt*" + 1 buffer-mode "rbin" + insert-file &cat #l1 #l3 + generate-hash + set-variable #l4 $result + !force delete-buffer "*ghrt*" + find-buffer "*ghrc*" + insert-string &spr "%s %s\n" #l4 #l3 + find-buffer "*ghru*" + set-variable %http-post-file &cat #l1 #l3 + set-variable %http-header &cat .git.hub-hdr "\r\nContent-Type: application/octet-stream" + !force insert-file &cat #l2 &rep &rep #l3 "_" "%5f" "." "%2e" + !iif ¬ $status -8 ml-write &spr "[Github Release Error: Failed to upload asset %s%s]" #l1 #l3 + set-variable #l5 &add #l5 1 + !done + find-buffer "*ghrc*" + !force 0 write-buffer &set %http-post-file &stat a &spr "%s../%s%s-sha265.txt" #l1 #l6 #l9 + set-variable %http-header &cat .git.hub-hdr "\r\nContent-Type: application/octet-stream" + find-buffer "*ghrc*" + !force insert-file &cat #l2 &rep &rep &spr "%s%s-sha265.txt" #l6 #l9 "_" "%5f" "." "%2e" + !iif ¬ $status -8 ml-write &spr "[Github Release Error: Failed to upload asset %s%s]" #l1 #l3 + set-variable #l5 &add #l5 1 + find-file @4 + beginning-of-buffer + replace-string "" #l9 + beginning-of-buffer + replace-string "\\\\" "\\\\\\\\" + beginning-of-buffer + replace-string "\"" "\\\\\"" + beginning-of-buffer + insert-string "{\"body\":\"" + replace-string "\n" "\\\\n" + 2 backward-delete-char + insert-string "\"}" + !force 0 write-buffer &set %http-post-file &stat a &spr "%s../readme.md.upl" #l1 + github-api-json &cat "releases/" #l8 + ml-write &spr "[Github Release: Complete, uploaded %d assets]" #l5 +!emacro + +define-macro github-build-release + !force set-variable #l0 @1 + !if &or ¬ $status &seq #l0 "" + set-variable #l0 @ml "MicroEmacs Version" + !iif &seq #l0 "" -8 ml-write "[Github Release Error: A version must be given]" + !endif + !iif ¬ &seq "R" &stat t &set #l1 &stat a .git.hub-rrt -8 ml-write &spr "[Github Release Error: Release readme template is not a regular file: %s]" #l1 + github-build "" &cat .git.hub-rtp #l0 + github-release #l8 #l0 #l9 #l1 +!emacro diff --git a/microemacs/doc/cygwin.txt b/microemacs/doc/cygwin.txt index f2cba8d92..e97a51b4f 100755 --- a/microemacs/doc/cygwin.txt +++ b/microemacs/doc/cygwin.txt @@ -4,7 +4,7 @@ > > Created By : Jon Green > Created : Sun Dec 8 14:46:52 2002 -> Last Modified : <20050513.0026> +> Last Modified : <20240909.2146> > File Name : cygwin.txt > @@ -70,8 +70,8 @@ RUNNING: SETTING UP: On running the editor for the first time then a configuration file is - created in your home directory "$HOME/.jasspa" which contains the editor - configuration setting. + created in your home directory "$HOME/.config/jasspa" which contains the + editor configuration setting. You can configure the editor to remember session history and preferred configuration:- @@ -86,7 +86,7 @@ SETTING UP: "N" - (Log Name) Enter your $USER name, the default one is guest. "P" - (Setup Path) Set up your local path, should be - /home//.jasspa + /home//.config/jasspa "F" - (Setup File) Enter your . diff --git a/microemacs/doc/m2nar001.2 b/microemacs/doc/m2nar001.2 index 64fe59e6e..2aaa9c44c 100755 --- a/microemacs/doc/m2nar001.2 +++ b/microemacs/doc/m2nar001.2 @@ -245,35 +245,29 @@ users execute a "\fCrehash\fR" command and then .Ht me 1 can be executed from the command line. .PP -By default a X-Windows terminal is displayed, ensure that \fC$DISPLAY\fR and -\fC$TERM\fR are correctly configured. To execute a terminal emulation then -execute \fBme\fR with the \fC\-n\fR option i.e. "\fCme\ \-n\fR". Note that -this is not required if you are using a \fCvt100\fR emulation. +By default a X-Windows terminal is displayed, ensure that \fC$DISPLAY\fR and \fC$TERM\fR are correctly configured. To +execute a terminal emulation then execute \fBme\fR with the \fC\-n\fR option i.e. "\fCme\ \-n\fR". Note that this is +not required if you are using a \fCvt100\fR emulation. .PP -When \*(mS is executed the local directory \fC~/.jasspa\fR is created for the -user settings. The user home directory may be changed by setting the -environment variable +When \*(mS is executed the local directory \fC~/.config/jasspa\fR is created for the user settings. The user home +directory may be changed by setting the environment variable .Ht $MEPATH 5 . .SS "UNIX Installation (Single User)" -Where the user is not permitted to install 3rd party applications in the -system directories then \*(mS may be installed locally as follows:- +Where the user is not permitted to install 3rd party applications in the system directories then \*(mS may be +installed locally as follows:- .BS -Create the directory \fC~/.jasspa\fR. +Create the directory \fC~/.config/jasspa\fR. .BU -Unpack and install the \fCjasspa-metree-YYYYMMDD.tar.gz\fR into this -directory. +Unpack and install the \fCjasspa-metree-YYYYMMDD.tar.gz\fR into this directory. .BU -If spelling dictionaries are required then place them in the \fIspelling\fR -sub-directory created when \fImetree\fR was unpacked. Unpack and install the -\fCspelling\fR into this directory. +If spelling dictionaries are required then place them in the \fIspelling\fR sub-directory created when \fImetree\fR +was unpacked. Unpack and install the \fCspelling\fR into this directory. .BU -If the standard icons are required for Gnome, KDE or some other window manager -then create the sub-directory \fC~/.jasspa/icons\fR and unpack and -install the icons into the new directory. +If the standard icons are required for Gnome, KDE or some other window manager then create the sub-directory +\fC~/.config/jasspa/icons\fR and unpack and install the icons into the new directory. .BU -The user files will be placed in the \fC~/.jasspa\fR directory by default. To -keep the user macros separate then the directory \fC~/.jasspa/$LOGNAME\fR may -be created and will identified as the users home directory. +The user files will be placed in the \fC~/.config/jasspa\fR directory by default. To keep the user macros separate +then the directory \fC~/.config/jasspa/$LOGNAME\fR may be created and will identified as the users home directory. .BU Unpack (or build) the executable and place in "\fC~/bin\fR" .BE diff --git a/microemacs/doc/m2nar003.2 b/microemacs/doc/m2nar003.2 index e55b414a0..4b403f762 100755 --- a/microemacs/doc/m2nar003.2 +++ b/microemacs/doc/m2nar003.2 @@ -87,7 +87,7 @@ location. .BP UNIX In the \s-1UNIX\s0 environment then the local directory is typically created in the users home directory obtained from the \fC/etc/passwd\fR file and is -called \fC~/.jasspa\fR. \*(mS will automatically look for this directory and +called \fC~/.config/jasspa\fR. \*(mS will automatically look for this directory and set the .Ht $user-path 5 variable to this value. The location may be overridden by setting the diff --git a/microemacs/doc/m5var089.5 b/microemacs/doc/m5var089.5 index 1ea933630..97abf2828 100755 --- a/microemacs/doc/m5var089.5 +++ b/microemacs/doc/m5var089.5 @@ -38,21 +38,18 @@ is undefined. The first directory in the \fB$MEPATH\fR variable is used as the .BU The directory is determined from the system: .br -\fBUNIX\fR: the home directory from \fC/etc/passwd\fR entry is used and -appended with \fC.jasspa\fR i.e. \fC$HOME/.jasspa\fR, if the sub-directory +\fBUNIX\fR: the home directory from \fC/etc/passwd\fR entry is used and appended with \fC.config/jasspa\fR i.e. +\fC$HOME/.config/jasspa\fR, if the sub-directory .Hl $user-name $user-name 5 -is detected in this directory then it is used instead -(\fC$HOME/.jasspa/$user\-name\fR). +is detected in this directory then it is used instead (\fC$HOME/.config/jasspa/$user\-name\fR). .br -\fBMicrosoft Windows\fR: the user application data directory is obtained from -the system and appended with \fCjasspa\fR i.e. \fC$APPDATA/jasspa\fR. If the -sub-directory +\fBMicrosoft Windows\fR: the user application data directory is obtained from the system and appended with +\fCjasspa\fR i.e. \fC$APPDATA/jasspa\fR. If the sub-directory .Hl $user-name $user-name 5 -is detected in this directory then it is used instead -(\fC$APPDATA/jasspa/$user\-name\fR). +is detected in this directory then it is used instead (\fC$APPDATA/jasspa/$user\-name\fR). .br -\fBMS-DOS\fR and older versions of \fBMicrosoft\fR \fBWindows\fR -without \fIInternet\fR \fIExplorer\fR \fI4.0\fR then a sub-directory +\fBMS-DOS\fR and older versions of \fBMicrosoft\fR \fBWindows\fR without \fIInternet\fR \fIExplorer\fR \fI4.0\fR then +a sub-directory .Hl $user-name $user-name 5 of the program directory diff --git a/microemacs/doc/m5var090.5 b/microemacs/doc/m5var090.5 index eeead6d43..8408b726f 100755 --- a/microemacs/doc/m5var090.5 +++ b/microemacs/doc/m5var090.5 @@ -145,35 +145,29 @@ Default install directories:- .I /usr/local/jasspa \- searching .LP -The default user location is defined as follows. +The default user location is defined as follows. .IP -\fI$(passwd-home)/.jasspa\fR \- searching +\fI$(passwd-home)/.config/jasspa\fR \- searching .PP -\*(mS searches for user defined configuration files in this directory and will -write new user configuration files to this directory. The behaviour of the -search may be over-ridden by setting some environment variables. +\*(mS searches for user defined configuration files in this directory and will write new user configuration files to +this directory. The behaviour of the search may be over-ridden by setting some environment variables. .TP \fC$MEUSERPATH\fR \- not searching .\" -Specified as a single pathname and redefines the \fI$user-path\fR where user -macros are placed, this overrides the \fI$(passwd-home)/.jasspa\fR directory -location. +Specified as a single pathname and redefines the \fI$user-path\fR where user macros are placed, this overrides the +\fI$(passwd-home)/.config/jasspa\fR directory location. .TP \fC$MEINSTALLPATH\fR \- searching .\" -Specified as multiple pathname components and overrides the default install -directory location (i.e. \fC/usr/local/jasspa\fR, etc. Typically used when the -system macro directory has been install in another location that is not -included in the default search path. This does not affect the user directory -location. +Specified as multiple pathname components and overrides the default install directory location (i.e. +\fC/usr/local/jasspa\fR, etc. Typically used when the system macro directory has been install in another location that +is not included in the default search path. This does not affect the user directory location. .TP \fC$MEPATH\fR \- not searching .\" -Overrides the \fI$(passwd-home)/.jasspa\fR and default search paths (including -\fC$MEINSTALLPATH\fR), \*(mS will use this directory as the search path. The -user directory is assumed to be the \s-1FIRST\s0 directory path in the string -unless the \fC$MEUSERPATH\fR environment variable is defined which specifies -the user path. +Overrides the \fI$(passwd-home)/.config/jasspa\fR and default search paths (including \fC$MEINSTALLPATH\fR), \*(mS +will use this directory as the search path. The user directory is assumed to be the \s-1FIRST\s0 directory path in the +string unless the \fC$MEUSERPATH\fR environment variable is defined which specifies the user path. .SS "Microsoft Windows" he defined search paths for \s-1WINDOWS\s0 are defined as follows:- .IP diff --git a/microemacs/doc/me.nrs b/microemacs/doc/me.nrs index 1f05fcc4f..9d11cd4f6 100755 --- a/microemacs/doc/me.nrs +++ b/microemacs/doc/me.nrs @@ -5101,13 +5101,11 @@ The \s-1UNIX\s0 path searching is improved. \fC/usr/local/microemacs\fR will be depreciated and replaced with \fC/usr/local/jasspa\fR in addition other standard path locations are supported on a per-platform basis. .BU "-" -On \s-1UNIX\s0 then the directory \fC~/.jasspa\fR shall contain the user -configuration files. Optionally the \fBcompany\fR, \fBspelling\fR and -\fBmacros\fR sub-directories may be included in this directory where access to -the system directory locations by the user is not permitted. +On \s-1UNIX\s0 then the directory \fC~/.config/jasspa\fR shall contain the user configuration files. Optionally the +\fBcompany\fR, \fBspelling\fR and \fBmacros\fR sub-directories may be included in this directory where access to the +system directory locations by the user is not permitted. .BU "-" -Concept of guest has been removed. \fCguest.emf\fR and \fCguest.erf\fR removed -replaced with \fInewuser\fR. +Concept of guest has been removed. \fCguest.emf\fR and \fCguest.erf\fR removed replaced with \fInewuser\fR. .Ht user-setup 3 no longer supports setting of name. .BU "-" diff --git a/microemacs/macros/newuser.emf b/microemacs/macros/newuser.emf index 4342f2b42..c87a06ced 100755 --- a/microemacs/macros/newuser.emf +++ b/microemacs/macros/newuser.emf @@ -29,13 +29,7 @@ !endif unset-variable .exit !emacro -!if &band $system 0x80 - set-variable .newuser.jasspa ".jasspa" - set-variable .newuser.pathdiv ":" -!else - set-variable .newuser.jasspa "jasspa" - set-variable .newuser.pathdiv ";" -!endif +set-variable .newuser.pathdiv &con &band $system 0x80 ":" ";" ; ; Create the file user.erf @@ -238,35 +232,38 @@ ; user has not fixed the environment, searching paths are being used. ; Therefore if the current $user-path is not a jasspa path we can ; create one and ME will automatically find one. - set-variable #l0 &spr "/%s/" .newuser.jasspa - !if &seq &rig $user-path &sub 0 &len #l0 #l0 - ; ends in "/.jaspa" or "/jasspa", this is okay as ME will ensure that - ; the $user-path points to a user area if possible (i.e. ~/ or $APPDATA/) + !if &seq &rig $user-path &sub 0 &len &set #l0 "/jasspa/" #l0 + ; ends in "/jasspa", this is okay as ME will ensure that the $user-path + ; points to a user area if possible (i.e. ~/ or $APPDATA/) + set-variable .newuser.user-path $user-path + !elif &seq &rig $user-path &sub 0 &len &set #l0 &spr "/jasspa/%s/" $user-name #l0 + ; ends in "/jaspa/", again this is okay set-variable .newuser.user-path $user-path !else - set-variable #l0 &spr "/%s/%s/" .newuser.jasspa $user-name - !if &seq &rig $user-path &sub 0 &len #l0 #l0 - ; ends in "/.jaspa/" or "/jasspa/", again this is okay - set-variable .newuser.user-path $user-path + ; add a .config/jasspa to the current $user-path if its the home directory and we are on UNIX + ; otherwise just add 'jasspa'. We will need to create it and mayby .config + !if ¬ &band $system 0x80 + set-variable .newuser.user-path &cat $user-path "jasspa/" + !elif &seq $user-path &stat a "~/" + set-variable .newuser.user-path &cat $user-path ".config/jasspa/" !else - ; add a .jasspa to the current $user-path and we will need to create it - set-variable .newuser.user-path &spr "%s%s/" $user-path .newuser.jasspa - !if &seq &set #l0 &stat "t" .newuser.user-path "X" - ; we will create this path which should mean that ME will ignore the current $user-path - set-variable .newuser.create-path .newuser.user-path - !if &seq &set #l1 &cat $user-path .newuser.pathdiv &lef .newuser.search-path &len #l1 - set-variable .newuser.search-path &rig .newuser.search-path &len #l1 - !elif &seq &set #l1 &cat &lef $user-path -1 .newuser.pathdiv &lef .newuser.search-path &len #l1 - set-variable .newuser.search-path &rig .newuser.search-path &len #l1 - !endif - set-variable .newuser.search-path &cat &cat .newuser.user-path .newuser.pathdiv .newuser.search-path - !elif &seq #l0 "D" - ; the directory already exists and ME did not use it so this is not one we can use - set-variable .newuser.user-path $user-path - !else - insert-string &spr "\nSuggested user path [%s] already exists as a file -\n Quit MicroEmacs and move the file if you wish to use this\n" .newuser.user-path - set-variable .newuser.user-path $user-path + set-variable .newuser.user-path &cat $user-path "jasspa/" + !endif + !if &seq &set #l0 &stat "t" .newuser.user-path "X" + ; we will create this path which should mean that ME will ignore the current $user-path + set-variable .newuser.create-path .newuser.user-path + !if &seq &set #l1 &cat $user-path .newuser.pathdiv &lef .newuser.search-path &len #l1 + set-variable .newuser.search-path &rig .newuser.search-path &len #l1 + !elif &seq &set #l1 &cat &lef $user-path -1 .newuser.pathdiv &lef .newuser.search-path &len #l1 + set-variable .newuser.search-path &rig .newuser.search-path &len #l1 !endif + set-variable .newuser.search-path &cat &cat .newuser.user-path .newuser.pathdiv .newuser.search-path + !elif &seq #l0 "D" + ; the directory already exists and ME did not use it so this is not one we can use + set-variable .newuser.user-path $user-path + !else + insert-string &spr "\nSuggested user path [%s] already exists as a file -\n Quit MicroEmacs and move the file if you wish to use this\n" .newuser.user-path + set-variable .newuser.user-path $user-path !endif !endif !endif @@ -303,49 +300,54 @@ !done insert-string &spr "User setup file: %s.emf\n\n" .newuser.setup-file - set-variable #l1 ® "/history/company" "company" - insert-string &spr "Looking for company file \"%s.emf\" ... " #l1 - !if &seq &find #l1 ".emf" "ERROR" - insert-string "[NOT FOUND]\n" - insert-string "\n" - insert-string "The company file contains template file format information that\n" - insert-string "may be used on a company wide basis. It also includes the basic\n" - insert-string "copyright information that is used in the header of all files\n" - insert-string "that are created.\n" - insert-string "\n" - insert-string "Do you want to set up a company file ? " - -1 recenter - 2 screen-update - set-variable #l0 @mc5 "Set up company file (?/y/n) ? " "ynYN" "(Y)es, (N)o, (C-g)Abort ? " - insert-string &spr "[%s]\n" &slow #l0 - !if &iseq #l0 "y" - insert-string "Enter existing or new name for the company file (8 chars): " + !if 0 + ; dont do company config here, easy to setup later with user-setup + set-variable #l1 ® "/history/company" "company" + insert-string &spr "Looking for company file \"%s.emf\" ... " #l1 + !if &seq &find #l1 ".emf" "ERROR" + insert-string "[NOT FOUND]\n" + insert-string "\n" + insert-string "The company file contains template file format information that\n" + insert-string "may be used on a company wide basis. It also includes the basic\n" + insert-string "copyright information that is used in the header of all files\n" + insert-string "that are created.\n" + insert-string "\n" + insert-string "Do you want to set up a company file ? " -1 recenter 2 screen-update - set-variable .newuser.company @ml1 "Company file" #l1 - insert-string &spr "[%s]\n" .newuser.company - set-registry "/history/company" .newuser.company - !if &seq &find .newuser.company ".emf" "ERROR" - ; Create a basic company file. - insert-string "Enter formal company name as will appear in copyright statements.\n" - insert-string "Company name (i.e. \"Acme Building Inc.\"): " + set-variable #l0 @mc5 "Set up company file (?/y/n) ? " "ynYN" "(Y)es, (N)o, (C-g)Abort ? " + insert-string &spr "[%s]\n" &slow #l0 + !if &iseq #l0 "y" + insert-string "Enter existing or new name for the company file (8 chars): " -1 recenter 2 screen-update - set-variable .newuser.company-name @ml "Company name" - insert-string &spr "[%s]\n\n" .newuser.company-name - !else - insert-string &spr "Looking for company file \"%s.emf\" ... [FOUND]\n" .newuser.company + set-variable .newuser.company @ml1 "Company file" #l1 + insert-string &spr "[%s]\n" .newuser.company + set-registry "/history/company" .newuser.company + !if &seq &find .newuser.company ".emf" "ERROR" + ; Create a basic company file. + insert-string "Enter formal company name as will appear in copyright statements.\n" + insert-string "Company name (i.e. \"Acme Building Inc.\"): " + -1 recenter + 2 screen-update + set-variable .newuser.company-name @ml "Company name" + insert-string &spr "[%s]\n\n" .newuser.company-name + !else + insert-string &spr "Looking for company file \"%s.emf\" ... [FOUND]\n" .newuser.company + !endif !endif + !else + insert-string "[FOUND]\n" + set-variable .newuser.company #l1 !endif - !else - insert-string "[FOUND]\n" - set-variable .newuser.company #l1 + insert-string &spr "\n" &slow #l0 !endif - insert-string &spr "\n" &slow #l0 ; create the user-path if required !if &exi .newuser.create-path insert-string &spr "Creating User Path: %s ... " .newuser.create-path - !force !force 0x100 file-op &lef .newuser.create-path &sub &len .newuser.create-path 1 + ; may need to create the ~/.config dir first + !iif ¬ &seq "D" &stat "t" &set #g1 &stat a &cat .newuser.create-path ".." !force !force 0x105 file-op #g1 + !force !force 0x100 file-op &lef .newuser.create-path -1 !if ¬ $status insert-string "[ERROR]\n" insert-string "ERROR: Cannot create the directory - resolve problem and re-start\n" @@ -373,6 +375,7 @@ ; ; Finished. insert-string "\n" + insert-string "\n" insert-string "Your basic environment is now set up. The files below have been\n" insert-string "created. The .emf files are MicroEmacs macro files and you may\n" insert-string "need to edit them in the future.\n" @@ -381,11 +384,13 @@ insert-string &spr " User Setup file: %s\n" &find .newuser.setup-file ".emf" !iif &exi .newuser.company insert-string &spr " Company Setup file: %s\n" &find .newuser.company ".emf" insert-string "\n" - insert-string "Use \"Tools -> User Setup\" from the menu bar or \"esc x user-setup\"\n" - insert-string "from the command line to configure other preferences. The preferences\n" - insert-string "include emulation modes for:\n" insert-string "\n" - insert-string " MicroEmacs v3.8, NEdit, Windows CUA and GNUEmacs.\n" + insert-string "Press 'f1' or 'esc =' to open the main menu bar.\n" + insert-string "\n" + insert-string "Use user-setup ('Tools' -> 'User Setup' from the menu or press\n" + insert-string "'esc x' and type 'user-setup') to make further configuration\n" + insert-string "changes, such as setting your language (on the 'Start-up' tab),\n" + insert-string "your preferred font and color scheme (on the 'Platform' tab).\n" insert-string "\n" insert-string "Press any key to Continue:\n" -1 recenter diff --git a/microemacs/macros/newuser.erf b/microemacs/macros/newuser.erf index f3823e2c2..9bb043de0 100755 --- a/microemacs/macros/newuser.erf +++ b/microemacs/macros/newuser.erf @@ -174,7 +174,6 @@ "msshift" = "0" "quiet" = "1" "rsif-com" = "-xml" -"setup-file" = "meuser" "spell" 2 { "autosave" = "0" "autospell" = "1" diff --git a/microemacs/release_readme.md b/microemacs/release_readme.md index e661b7a45..93ad1a1dc 100644 --- a/microemacs/release_readme.md +++ b/microemacs/release_readme.md @@ -37,7 +37,7 @@ INSTALLERS - Homebrew installers for Linux and macOS, details to follow. -- Jasspa_MicroEmacs__installer_windows.msi contains the binaries for Windows, the macros and help file, +- [Jasspa_MicroEmacs__installer_windows.msi](https://github.com/bjasspa/jasspa/releases/download/me_/Jasspa_MicroEmacs__installer_windows.msi) contains the binaries for Windows, the macros and help file, simply download and run to create a fully working environment. Spelling dictionary can be downloaded and installed by MicroEmacs as and when required. @@ -56,9 +56,9 @@ To build a more complete, native environment do the following: a. **Required:** Binaries for your platform (Jasspa_MicroEmacs__bin_\\_binaries.zip) - b. **Required:** Macro files (Jasspa_MicroEmacs__macros.zip) + b. **Required:** Macro files ([Jasspa_MicroEmacs__macros.zip](https://github.com/bjasspa/jasspa/releases/download/me_/Jasspa_MicroEmacs__macros.zip)) - c. Help file (Jasspa_MicroEmacs__help_ehf.zip) + c. Help file ([Jasspa_MicroEmacs__help_ehf.zip](https://github.com/bjasspa/jasspa/releases/download/me_/Jasspa_MicroEmacs__help_ehf.zip)) d. Spelling dictionaries for any language you require (Jasspa_MicroEmacs__spelling_\.zip) diff --git a/microemacs/src/dosterm.c b/microemacs/src/dosterm.c index 1f5c8b4f5..4d18355cf 100755 --- a/microemacs/src/dosterm.c +++ b/microemacs/src/dosterm.c @@ -179,10 +179,8 @@ meSetupPathsAndUser(void) { meStrcpy(buff,homedir) ; meStrcat(buff,"jasspa") ; - if(((ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath)) > 0) && !gotUserPath) - /* as this is the user's area, use this directory unless we find - * a .../<$user-name>/ directory */ - gotUserPath = -1 ; + /* as this is the user's area, use this directory as user path (with or without .../<$user-name>/ sub-directory */ + ll = mePathAddSearchPath(ll,evalResult,buff,1,&gotUserPath); } /* Get the system path of the installed macros. Use $MEINSTPATH as the @@ -190,7 +188,7 @@ meSetupPathsAndUser(void) if(((ss = meGetenv ("MEINSTALLPATH")) != NULL) && (ss[0] != '\0')) { meStrcpy(buff,ss) ; - ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath) ; + ll = mePathAddSearchPath(ll,evalResult,buff,0,&gotUserPath) ; } /* also check for directories in the same location as the binary */ @@ -199,7 +197,7 @@ meSetupPathsAndUser(void) ii = (((size_t) ss) - ((size_t) meProgName)) ; meStrncpy(buff,meProgName,ii) ; buff[ii] = '\0' ; - ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath) ; + ll = mePathAddSearchPath(ll,evalResult,buff,0,&gotUserPath) ; } if(!gotUserPath && (homedir != NULL)) { diff --git a/microemacs/src/eextrn.h b/microemacs/src/eextrn.h index ed27b7e9d..e7b773ebf 100755 --- a/microemacs/src/eextrn.h +++ b/microemacs/src/eextrn.h @@ -337,7 +337,7 @@ extern int fnamecmp(meUByte *f1, meUByte *f2); #define gfsERRON_DIR 4 extern int getFileStats(meUByte *file, int flag, meStat *stats, meUByte *lname); extern int mePathAddSearchPath(int index, meUByte *path_name, - meUByte *path_base, int *gotUserPath); + meUByte *path_base, int isUsrArea, int *gotUserPath); #define meFL_CHECKDOT 0x01 #define meFL_USESRCHPATH 0x02 #define meFL_USEPATH 0x04 diff --git a/microemacs/src/file.c b/microemacs/src/file.c index 2c23d633c..9a428cd5a 100755 --- a/microemacs/src/file.c +++ b/microemacs/src/file.c @@ -519,7 +519,7 @@ fnamecmp(meUByte *f1, meUByte *f2) /* Search the directory and subdirectories for MicroEmacs macro directories */ int -mePathAddSearchPath(int index, meUByte *path_name, meUByte *path_base, int *gotUserPath) +mePathAddSearchPath(int index, meUByte *path_name, meUByte *path_base, int isUsrArea, int *gotUserPath) { /* Common sub-directories of JASSPAs MicroEmacs */ static meUByte *subdirs[] = @@ -529,66 +529,65 @@ mePathAddSearchPath(int index, meUByte *path_name, meUByte *path_base, int *gotU (meUByte *) "spelling", /* Spelling dictionaries */ NULL } ; - meUByte cc, *pp, *ss, base_name[meBUF_SIZE_MAX]; - int ii; + meUByte cc, *ss, base_name[meBUF_SIZE_MAX]; + int ii, jj, ll; /* Iterate over all of the paths */ while(*path_base != '\0') { /* Construct the base name */ - pp = base_name; + ll = 0; while((cc = *path_base) != '\0') { path_base++; if(cc == mePATH_CHAR) break; - *pp++ = cc; + base_name[ll++] = cc; } /* Clean up any trailing directory characters */ - if(((size_t) (pp - base_name)) < _ROOT_DIR_LEN) + if(ll < _ROOT_DIR_LEN) continue; - if(pp[-1] == DIR_CHAR) - pp--; - *pp = '\0' ; + if(base_name[ll-1] == DIR_CHAR) + ll--; + base_name[ll] = '\0' ; if(getFileStats(base_name,0,NULL,NULL) & meIOTYPE_DIRECTORY) { - *pp++ = DIR_CHAR; + base_name[ll++] = DIR_CHAR; /* check for base_name/$user-name first */ if(meUserName != NULL) { - meStrcpy(pp,meUserName); + meStrcpy(base_name+ll,meUserName); if(getFileStats(base_name,0,NULL,NULL) & meIOTYPE_DIRECTORY) { /* it exists, add it to the front if we haven't got a user * path yet or to the end otherwise */ - ii = meStrlen(base_name); - if(*gotUserPath <= 0) + jj = ll + meStrlen(meUserName); + if(*gotUserPath == 0) { - *gotUserPath = 1 ; + *gotUserPath = 1; if(index) { - base_name[ii++] = mePATH_CHAR; - meStrcpy(base_name+ii,path_name); + base_name[jj++] = mePATH_CHAR; + memcpy(base_name+jj,path_name,index+1); } - meStrcpy(path_name,base_name); + memcpy(path_name,base_name,jj+index+1); } else { if(index) path_name[index++] = mePATH_CHAR; - meStrcpy(path_name+index,base_name); + memcpy(path_name+index,base_name,jj+1); } - index += ii; + index += jj; } } - /* Append the search paths if necessary. We construct the standard JASSPA MicroEmacs * paths and then test for the existance of the directory. If the directory exists then * we add it to the search path. We do not add any directories to the search path that * do not exist. */ for(ii=0 ; (ss=subdirs[ii]) != NULL ; ii++) { - meStrcpy(pp,ss); + meStrcpy(base_name+ll,ss); /* Test the directory for existance, if it does not exist then do not add it as we * do not want to search any directory unecessarily. */ if(getFileStats(base_name,0,NULL,NULL) & meIOTYPE_DIRECTORY) @@ -596,15 +595,29 @@ mePathAddSearchPath(int index, meUByte *path_name, meUByte *path_base, int *gotU /* it exists, add it */ if(index) path_name[index++] = mePATH_CHAR; - meStrcpy(path_name+index,base_name); - index += meStrlen(base_name); + jj = ll + meStrlen(ss); + memcpy(path_name+index,base_name,jj+1); + index += jj; + } + } + ll--; + if((*gotUserPath == 0) && isUsrArea) + { + *gotUserPath = 1; + if(index) + { + base_name[ll++] = mePATH_CHAR; + memcpy(base_name+ll,path_name,index+1); } + memcpy(path_name,base_name,ll+index+1); + } + else + { + if(index) + path_name[index++] = mePATH_CHAR; + memcpy(path_name+index,base_name,ll+1); } - if(index) - path_name[index++] = mePATH_CHAR; - *--pp = '\0'; - meStrcpy(path_name+index,base_name); - index += (int) ((size_t) (pp - base_name)); + index += ll; } } return index; diff --git a/microemacs/src/readme.txt b/microemacs/src/readme.txt index 21d21a610..8893607e1 100755 --- a/microemacs/src/readme.txt +++ b/microemacs/src/readme.txt @@ -216,27 +216,27 @@ INSTALLATION execute me with the -n option i.e. "me -n". Note that this is not required if you are using a vt100 emulation. - When MicroEmacs is executed the local directory ~/.jasspa is created for - the user settings. The user home directory may be changed by setting the - environment variable $MEPATH(5). + When MicroEmacs is executed the local directory ~/.config/jasspa is + created for the user settings. The user home directory may be changed by + setting the environment variable $MEPATH(5). UNIX Installation (Single User) Where the user is not permitted to install 3rd party applications in the system directories then MicroEmacs may be installed locally as follows:- - * Create the directory ~/.jasspa. - * Unpack and install the jasspa-metree-YYYYMMDD.tar.gz into this + * Create the directory ~/.config/jasspa. + * Unpack and install the jasspa-metree-YYYYMMDD.tar.gz into this directory. * If spelling dictionaries are required then place them in the spelling - sub-directory created when metree was unpacked. Unpack and install + sub-directory created when metree was unpacked. Unpack and install the spelling into this directory. - * If the standard icons are required for Gnome, KDE or some other - window manager then create the sub-directory ~/.jasspa/icons and - unpack and install the icons into the new directory. - * The user files will be placed in the ~/.jasspa directory by default. - To keep the user macros separate then the directory - ~/.jasspa/$LOGNAME may be created and will identified as the users - home directory. + * If the standard icons are required for Gnome, KDE or some other + window manager then create the sub-directory ~/.config/jasspa/icons + and unpack and install the icons into the new directory. + * The user files will be placed in the ~/.config/jasspa directory by + default. To keep the user macros separate then the directory + ~/.config/jasspa/$LOGNAME may be created and will identified as the + users home directory. * Unpack (or build) the executable and place in "~/bin" MicroEmacs may be executed after it has been re-hashed (depending on the @@ -610,9 +610,9 @@ USER PROFILES UNIX In the UNIX environment then the local directory is typically created in the users home directory obtained from the /etc/passwd file and is - called ~/.jasspa. MicroEmacs will automatically look for this - directory and set the $user-path(5) variable to this value. The - location may be overridden by setting the environment variable + called ~/.config/jasspa. MicroEmacs will automatically look for this + directory and set the $user-path(5) variable to this value. The + location may be overridden by setting the environment variable $MEUSERPATH(5) to reference a different directory location. DOS For MS-DOS environments, there is typically no user directory, it is diff --git a/microemacs/src/unixterm.c b/microemacs/src/unixterm.c index 94d127dcc..8e31635d1 100755 --- a/microemacs/src/unixterm.c +++ b/microemacs/src/unixterm.c @@ -527,8 +527,8 @@ meSetupPathsAndUser(void) #endif static meUByte lpath[] = _SEARCH_PATH; struct passwd *pwdp; /* Password structure entry */ - meUByte *ss, buff[meBUF_SIZE_MAX] ; - int ii, ll, gotUserPath ; + meUByte *ss, buff[meBUF_SIZE_MAX]; + int ii, ll, gotUserPath; if((meUserName == NULL) && ((ss = meGetenv ("MENAME")) != NULL) && (ss[0] != '\0')) @@ -591,21 +591,18 @@ meSetupPathsAndUser(void) /* construct the search-path */ /* put the $user-path first */ if((gotUserPath = (meUserPath != NULL))) - meStrcpy(evalResult,meUserPath) ; + meStrcpy(evalResult,meUserPath); else - evalResult[0] = '\0' ; - ll = meStrlen(evalResult) ; + evalResult[0] = '\0'; + ll = meStrlen(evalResult); - /* TODO should this be changed to ~/.config/jasspa ? */ - /* look for the ~/.jasspa directory */ + /* look for the ~/.config/jasspa directory */ if(homedir != NULL) { - meStrcpy(buff,homedir) ; - meStrcat(buff,".jasspa") ; - if(((ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath)) > 0) && !gotUserPath) - /* as this is the user's area, use this directory unless we find - * a .../<$user-name>/ directory */ - gotUserPath = -1 ; + meStrcpy(buff,homedir); + meStrcat(buff,".config/jasspa"); + /* as this is the user's area, use this directory as user path (with or without .../<$user-name>/ sub-directory */ + ll = mePathAddSearchPath(ll,evalResult,buff,1,&gotUserPath); } /* Get the system path of the installed macros. Use $MEINSTPATH as the @@ -614,7 +611,7 @@ meSetupPathsAndUser(void) (((ss = lpath) != NULL) && (ss[0] != '\0'))) { meStrcpy(buff,ss) ; - ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath) ; + ll = mePathAddSearchPath(ll,evalResult,buff,0,&gotUserPath) ; } /* also check for directories in the same location as the binary */ @@ -623,13 +620,13 @@ meSetupPathsAndUser(void) ii = (((size_t) ss) - ((size_t) meProgName)) ; meStrncpy(buff,meProgName,ii) ; buff[ii] = '\0' ; - ll = mePathAddSearchPath(ll,evalResult,buff,&gotUserPath) ; + ll = mePathAddSearchPath(ll,evalResult,buff,0,&gotUserPath) ; } #if MEOPT_TFS /* also check for the built-in file system */ if(tfsdev != NULL) - ll = mePathAddSearchPath(ll,evalResult,(meUByte *) "tfs://",&gotUserPath) ; + ll = mePathAddSearchPath(ll,evalResult,(meUByte *) "tfs://",0,&gotUserPath) ; #endif if(!gotUserPath && (homedir != NULL)) diff --git a/microemacs/src/winterm.c b/microemacs/src/winterm.c index 436d9ef0c..b86746981 100755 --- a/microemacs/src/winterm.c +++ b/microemacs/src/winterm.c @@ -5581,11 +5581,8 @@ meSetupPathsAndUser(void) { strcpy(buff,appData); strcat(buff,"/jasspa"); - if(((ll = mePathAddSearchPath(ll,evalResult,(meUByte *) buff,&gotUserPath)) > 0) && - !gotUserPath) - /* as this is the user's area, use this directory unless we find - * a .../<$user-name>/ directory */ - gotUserPath = -1; + /* as this is the user's area, use this directory as user path (with or without .../<$user-name>/ sub-directory */ + ll = mePathAddSearchPath(ll,evalResult,(meUByte *) buff,1,&gotUserPath); } /* Get the system path of the installed macros. Use $MEINSTPATH as the @@ -5593,7 +5590,7 @@ meSetupPathsAndUser(void) if(((ss = meGetenv("MEINSTALLPATH")) != NULL) && (ss[0] != '\0')) { strcpy(buff,ss); - ll = mePathAddSearchPath(ll,evalResult,(meUByte *) buff,&gotUserPath); + ll = mePathAddSearchPath(ll,evalResult,(meUByte *) buff,0,&gotUserPath); } /* also check for directories in the same location as the binary */ @@ -5602,12 +5599,12 @@ meSetupPathsAndUser(void) ii = (((size_t) ss) - ((size_t) meProgName)); meStrncpy(buff,meProgName,ii); buff[ii] = '\0'; - ll = mePathAddSearchPath(ll,evalResult,(meUByte *) buff,&gotUserPath); + ll = mePathAddSearchPath(ll,evalResult,(meUByte *) buff,0,&gotUserPath); } #if MEOPT_TFS /* also check for the built-in file system */ if(tfsdev != NULL) - ll = mePathAddSearchPath(ll,evalResult,(meUByte *) "tfs://",&gotUserPath); + ll = mePathAddSearchPath(ll,evalResult,(meUByte *) "tfs://",0,&gotUserPath); #endif if(!gotUserPath && (appData != NULL)) {