<p><a href="https://github.com/elextr" class="user-mention">@elextr</a></p>
<blockquote>
<p>a normal plugin would use document_set_filetype() but I don't know if its available in the restricted Geanylua API.</p>
</blockquote>
<p>"normal" plugin? :)<br>
I use local <a href="https://github.com/geany/geany-plugins/blob/master/geanylua/docs/geanylua-ref.html">geanylua-ref.html</a>. Also I tried to find <code>document_set_filetype()</code> in source files of Geanylua, but without success.</p>
<p>Maybe try something like</p>
<div class="highlight highlight-source-diff"><pre><span class="pl-md">--- "geanylua/glspi_doc.c"</span>
<span class="pl-mi1">+++ "geanylua/glspi_doc.c"</span>
<span class="pl-mdr">@@ -36,8 +36,10 @@</span>
                if (!lua_isstring(L, 1))        { return FAIL_STRING_ARG(1); }
                fn=lua_tostring(L, 1);
                if ( '\0' == fn[0] ) { fn = NULL; }
<span class="pl-mi1"><span class="pl-mi1">+</span>                ft=lua_tostring(L, 2);</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>                if ( '\0' == fn[0] ) { fn = NULL; }</span>
        }
<span class="pl-md"><span class="pl-md">-</span>  document_new_file(fn, NULL, NULL);</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>        document_new_file(fn, ft, NULL);</span>
        return 0;
 }</pre></div>
<p>?<br>
Function <code>glspi_newfile</code>, i.e. minimal effort (?). And use like</p>
<div class="highlight highlight-source-lua"><pre><span class="pl-k">local</span> t <span class="pl-k">=</span> geany.<span class="pl-c1">fileinfo</span>();
geany.<span class="pl-c1">newfile</span>(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-pds">"</span></span>, t.<span class="pl-smi">type</span>);</pre></div>
<p>for untitled document/new tab.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany-plugins/issues/646#issuecomment-345476945">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJx1Da58sQmBVxB5_LS5gKSp6lAQfks5s312qgaJpZM4Qi3Uc">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJylpphIqt9E6-v4zrm0920N4ShEvks5s312qgaJpZM4Qi3Uc.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany-plugins/issues/646#issuecomment-345476945"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany-plugins","title":"geany/geany-plugins","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany-plugins"}},"updates":{"snippets":[{"icon":"PERSON","message":"@Skif-off in #646: @elextr \r\n\u003ea normal plugin would use document_set_filetype() but I don't know if its available in the restricted Geanylua API.\r\n\r\n\"normal\" plugin? :)\r\nI use local [geanylua-ref.html](https://github.com/geany/geany-plugins/blob/master/geanylua/docs/geanylua-ref.html). Also I tried to find ```document_set_filetype()``` in source files of Geanylua, but without success.\r\n\r\nMaybe try something like\r\n```diff\r\n--- \"geanylua/glspi_doc.c\"\r\n+++ \"geanylua/glspi_doc.c\"\r\n@@ -36,8 +36,10 @@\r\n \t\tif (!lua_isstring(L, 1))\t{ return FAIL_STRING_ARG(1); }\r\n \t\tfn=lua_tostring(L, 1);\r\n \t\tif ( '\\0' == fn[0] ) { fn = NULL; }\r\n+\t\tft=lua_tostring(L, 2);\r\n+\t\tif ( '\\0' == fn[0] ) { fn = NULL; }\r\n \t}\r\n-\tdocument_new_file(fn, NULL, NULL);\r\n+\tdocument_new_file(fn, ft, NULL);\r\n \treturn 0;\r\n }\r\n ```\r\n? \r\nFunction ```glspi_newfile```, i.e. minimal effort (?). And use like\r\n```lua\r\nlocal t = geany.fileinfo();\r\ngeany.newfile(\"\", t.type);\r\n```\r\nfor untitled document/new tab."}],"action":{"name":"View Issue","url":"https://github.com/geany/geany-plugins/issues/646#issuecomment-345476945"}}}</script>