* patch for pointers, callbacks, and dynamically linked libraries in emacs 22.3
@ 2009-05-16 1:29 Naveen Garg
0 siblings, 0 replies; only message in thread
From: Naveen Garg @ 2009-05-16 1:29 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1.1: Type: text/plain, Size: 609 bytes --]
Hello everyone,
Like you, I spend much time in Emacs.
When I go out of Emacs, I have AutoHotkey with me. But really, I never
leave either now.
AutoHotkey is a scripting language for win32 also distributed under GPL.
Here is a patch that dynamically loads AutoHotkey into Emacs.
Other features:
Access to pointers. (strings for now, will add pointers to other
LispObjects )
Callback to eval.
SendMessage to other windows (AutoHotkey).
AutoHotkey already has dynamic function calls by pointer, will add a
callback to it from Emacs, until then sendmessage should do it.
Thanks,
Naveen,
http://www.ahklisp.com
[-- Attachment #1.2: Type: text/html, Size: 719 bytes --]
[-- Attachment #2: patch-fns.c --]
[-- Type: application/octet-stream, Size: 2887 bytes --]
diff --git a/fns.c b/fns.c
index 5df8be2..085f4f3 100644
--- a/fns.c
+++ b/fns.c
@@ -2306,7 +2307,27 @@ internal_equal (o1, o2, depth, props)
return 0;
}
-\f
+
+LRESULT sendAhk(char msg[200], char *target)
+{
+ COPYDATASTRUCT cd;
+ int port = 100;
+ cd.dwData = port;
+ cd.cbData = 200 ;
+ cd.lpData = msg ;
+ WPARAM id = 951753;
+ HWND hHost = FindWindow(NULL, target);
+ return SendMessage(hHost, WM_COPYDATA, id, (LPARAM)&cd);
+}
+
+
+EXPORT char *callback(char *expression)
+{
+ // expression must return a string, should change this to Lisp_Object
+ Lisp_Object result = Feval(Fread(build_string(expression)));
+ return SDATA(result);
+}
+
extern Lisp_Object Fmake_char_internal ();
DEFUN ("fillarray", Ffillarray, Sfillarray, 2, 2, 0,
@@ -5481,6 +5502,55 @@ FUNCTION is called with two arguments, KEY and VALUE. */)
return Qnil;
}
+// Dynamic Shared Objects and Callbacks in emacs: naveen.garg@gmail.com, GPL v2.
+DEFUN ("loadmodule", Floadmodule, Sloadmodule, 1, 3, 0,
+ doc: /* load dynamic shared object or dll
+ parameters: 3 strings: filename, option, parameter */)
+ (o1, o2, o3)
+ Lisp_Object o1, o2, o3;
+{
+ typedef int (*pfunc)(char *fileName, char *argv, char *args);
+ char *pointer1 = SDATA(o1);
+ char *pointer2 = SDATA(o2);
+ char *pointer3 = SDATA(o3);
+ /*Windows handle*/
+ HANDLE hdll;
+
+ /*A pointer to a function*/
+ pfunc ahkdll;
+
+ /*LoadLibrary*/
+ hdll = LoadLibrary("AutoHotkey.dll");
+
+ /*GetProcAddress*/
+ ahkdll = (pfunc)GetProcAddress(hdll, "ahkdll");
+ Sleep(1000);
+ /*Call the function*/
+ ahkdll(pointer1, pointer2, pointer3); // "dllclient.ahk"
+ return Qt;
+}
+
+DEFUN ("pointer", Fpointer, Spointer, 1, 1, 0,
+ doc: /* returns pointer to lisp object and also uses sendmessage() to send it to possibly a shared module */)
+ (o1)
+ Lisp_Object o1;
+{
+ char *pointer = SDATA(o1);
+ return make_number((int)pointer);
+}
+
+DEFUN ("sendmsg", Fsendmsg, Ssendmsg, 1, 1, 0,
+ doc: /* returns sendmsg to lisp object and also uses sendmessage() to send it to possibly a shared module
+ // char aString[200] = {0} ;
+ // snprintf(aString, 200, "%s", pointer);
+ // sendAhk(aString, "dllclient.ahk");
+ */)
+ (o1)
+ Lisp_Object o1;
+{
+ char *pointer = SDATA(o1);
+ return make_number(sendAhk(pointer, "dllclient.ahk"));
+}
DEFUN ("define-hash-table-test", Fdefine_hash_table_test,
@@ -5878,6 +5948,9 @@ both `use-dialog-box' and this variable are non-nil. */);
defsubr (&Slax_plist_put);
defsubr (&Seql);
defsubr (&Sequal);
+ defsubr (&Spointer);
+ defsubr (&Sloadmodule);
+ defsubr (&Ssendmsg);
defsubr (&Sequal_including_properties);
defsubr (&Sfillarray);
defsubr (&Sclear_string);
@@ -5922,3 +5995,4 @@ init_fns ()
/* arch-tag: 787f8219-5b74-46bd-8469-7e1cc475fa31
(do not change this comment) */
+
[-- Attachment #3: patch-lisp.h --]
[-- Type: application/octet-stream, Size: 684 bytes --]
diff --git a/lisp.h b/lisp.h
index 8b4f945..7c5c142 100644
--- a/lisp.h
+++ b/lisp.h
@@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
-
+#define EXPORT __declspec(dllexport)
#ifndef EMACS_LISP_H
#define EMACS_LISP_H
@@ -3466,3 +3467,6 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
/* arch-tag: 9b2ed020-70eb-47ac-94ee-e1c2a5107d5e
(do not change this comment) */
+
+
+EXPORT char *callback(char *expression); // calls eval on expression : naveen.garg@gmail.com
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-05-16 1:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-16 1:29 patch for pointers, callbacks, and dynamically linked libraries in emacs 22.3 Naveen Garg
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.