From 0b6b83f5a87dd63242cd414eabc45e48f5a907f5 Mon Sep 17 00:00:00 2001 From: Skif-off Date: Thu, 30 Nov 2017 11:07:48 +0400 Subject: [PATCH 1/3] GeanyLua: Add filetype to set in geany.newfile() --- geanylua/docs/geanylua-ref.html | 24 ++++++++++++++++++------ geanylua/glspi_doc.c | 17 ++++++++++++++--- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/geanylua/docs/geanylua-ref.html b/geanylua/docs/geanylua-ref.html index 9795c165e..2c5096c8b 100644 --- a/geanylua/docs/geanylua-ref.html +++ b/geanylua/docs/geanylua-ref.html @@ -136,7 +136,7 @@ -   function newfile ( [filename] )
+   function newfile ( [filename [, filetype] )
-- Create a new document. @@ -756,11 +756,23 @@

-

geany.newfile ( [filename] )

-When called with one argument, creates a new document with the specified -filename.

When called with no arguments, creates a new, untitled document. -



- +

geany.newfile ( [filename [, filetype] )

+

When called with no arguments, creates a new, untitled document.

+

When called with one argument, creates a new document with the specified +filename.

+

When called with two argument, creates a new document with the specified +filename and filetype (a one-word description of the filetype, +e.g. "C" or "Python".). If you want untitled document then set filename as "".

+

So you can use it like this:

+
local s = geany.selection();
+
+if (s ~= "") and (s ~= nil) then
+  local t = geany.fileinfo();
+  geany.newfile("", t.type);
+  geany.selection(s);
+end
+

(create a new, untitled document, with selected text and auto set filetype).

+


geany.open ( [filename]|[index] )

diff --git a/geanylua/glspi_doc.c b/geanylua/glspi_doc.c index 888ce8d55..b536033e8 100644 --- a/geanylua/glspi_doc.c +++ b/geanylua/glspi_doc.c @@ -32,12 +32,23 @@ static gint glspi_filename(lua_State* L) static gint glspi_newfile(lua_State* L) { const gchar *fn=NULL; - if (lua_gettop(L)>0) { + GeanyFiletype *ft=NULL; + switch (lua_gettop(L)) { + case 0: break; + case 2: + if (!lua_isstring(L, 2)) { return FAIL_STRING_ARG(2); } + const gchar *tmp=lua_tostring(L, 2); + if ( '\0' == tmp[0] ) { + ft=NULL; + } else { + ft=filetypes_lookup_by_name(tmp); + } + default: if (!lua_isstring(L, 1)) { return FAIL_STRING_ARG(1); } fn=lua_tostring(L, 1); - if ( '\0' == fn[0] ) { fn = NULL; } + if ( '\0' == fn[0] ) { fn=NULL; } } - document_new_file(fn, NULL, NULL); + document_new_file(fn, ft, NULL); return 0; } From c91ae6f9254f61821fcaff10fece0b11ce8b560a Mon Sep 17 00:00:00 2001 From: Skif-off Date: Thu, 30 Nov 2017 22:36:35 +0400 Subject: [PATCH 2/3] GeanyLua: trivial for Travis --- geanylua/docs/geanylua-ref.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/geanylua/docs/geanylua-ref.html b/geanylua/docs/geanylua-ref.html index 2c5096c8b..c10795842 100644 --- a/geanylua/docs/geanylua-ref.html +++ b/geanylua/docs/geanylua-ref.html @@ -758,8 +758,7 @@


geany.newfile ( [filename [, filetype] )

When called with no arguments, creates a new, untitled document.

-

When called with one argument, creates a new document with the specified -filename.

+

When called with one argument, creates a new document with the specified filename.

When called with two argument, creates a new document with the specified filename and filetype (a one-word description of the filetype, e.g. "C" or "Python".). If you want untitled document then set filename as "".

From 5bb1ca77d8dcd2af1b8cbf0145b5e58f0277495f Mon Sep 17 00:00:00 2001 From: Skif-off Date: Sun, 17 Dec 2017 04:34:03 +0400 Subject: [PATCH 3/3] GeanyLua: geanylua-ref.html: Fix "zebra" (class "odd"/"even") --- geanylua/docs/geanylua-ref.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/geanylua/docs/geanylua-ref.html b/geanylua/docs/geanylua-ref.html index c10795842..e1c4f3e35 100644 --- a/geanylua/docs/geanylua-ref.html +++ b/geanylua/docs/geanylua-ref.html @@ -181,27 +181,27 @@ -- Send a GTK signal to a Geany interface widget. - +   function status ( message )
-- Send a string to display in the status tab of the messages window. - +   function text ( [content] )
-- Get or set the contents of the entire document. - +   function word ( [position] )
-- Get the word at the specified location. - +   function xsel ( [text] )
-- Get or set the contents of the primary X selection. - +   function yield ()
-- Refreshes the user interface.