]> gitweb.factorcode.org Git - factor.git/commitdiff
Split off windows specifics. Find path in registry first.
authornomennescio <nomennescio@factorcode.org>
Tue, 12 Jul 2022 20:52:20 +0000 (22:52 +0200)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 1 Dec 2022 16:24:57 +0000 (08:24 -0800)
basis/editors/emacs/emacs.factor
basis/editors/emacs/windows/windows.factor [new file with mode: 0644]

index f1b12b6211629af9cb57a87c415d7785ebdd892b..9ce457a43a11f5d6eb5fe531f2a2093f5cbbcb83 100644 (file)
@@ -1,5 +1,5 @@
 USING: combinators.short-circuit editors io.standard-paths
-kernel make math.parser namespaces sequences system ;
+kernel make math.parser namespaces sequences system vocabs ;
 IN: editors.emacs
 
 SINGLETON: emacs
@@ -14,13 +14,6 @@ HOOK: find-emacsclient os ( -- path )
 M: object find-emacsclient
     "emacsclient" ?find-in-path ;
 
-M: windows find-emacsclient
-    {
-        [ { "Emacs" } "emacsclientw.exe" find-in-applications ]
-        [ { "Emacs" } "emacsclient.exe" find-in-applications ]
-        [ "emacsclient.exe" ]
-    } 0|| ;
-
 M: emacs editor-command
     [
         emacsclient-path get [ find-emacsclient ] unless* ,
@@ -28,3 +21,5 @@ M: emacs editor-command
         number>string "+" prepend ,
         ,
     ] { } make ;
+
+os windows? [ "editors.emacs.windows" require ] when
\ No newline at end of file
diff --git a/basis/editors/emacs/windows/windows.factor b/basis/editors/emacs/windows/windows.factor
new file mode 100644 (file)
index 0000000..d32a520
--- /dev/null
@@ -0,0 +1,17 @@
+! Copyright (C) 2022 nomennescio
+! See http://factorcode.org/license.txt for BSD license.
+USING: combinators.short-circuit continuations editors editors.emacs
+io.pathnames io.standard-paths kernel make math.parser
+namespaces sequences system windows.advapi32 windows.registry ;
+IN: editors.emacs.windows
+
+CONSTANT: registry-path-to-emacs "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\emacs.exe"
+
+M: windows find-emacsclient
+    {
+        [ [ HKEY_LOCAL_MACHINE registry-path-to-emacs "" query-registry
+            parent-directory "emacsclientw.exe" append-path ] [ drop f ] recover ]
+        [ { "Emacs" } "emacsclientw.exe" find-in-applications ]
+        [ { "Emacs" } "emacsclient.exe" find-in-applications ]
+        [ "emacsclient.exe" ]
+    } 0|| ;
\ No newline at end of file