Community
    • Login

    *_js.php as javascript style

    Scheduled Pinned Locked Moved General Discussion
    6 Posts 2 Posters 1.1k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jesus CamposJ Offline
      Jesus Campos
      last edited by

      Hi,

      It’s possible to auto set the language as javascript when the file ends as _js.php? Hi already set in the Style Configurator -> user extensions _js.php but it didn’t work… It would save me a lot of time.

      Regards!

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn @Jesus Campos
        last edited by

        @Jesus-Campos

        Ummm… all of that is based upon a file’s extension. The extension is (roughly) defined as whatever follows the final . in a file’s pathname, after the final path separator (e.g. \). By now you should have your answer, but in case you don’t I’ll give it to you: What you are asking isn’t reasonably possible.

        Alan KilbornA 1 Reply Last reply Reply Quote 1
        • Alan KilbornA Offline
          Alan Kilborn @Alan Kilborn
          last edited by

          @Jesus-Campos

          I have reconsidered. I think a script could do it. If you are interested in, say a Pythonscript solution, reply back.

          1 Reply Last reply Reply Quote 3
          • Jesus CamposJ Offline
            Jesus Campos
            last edited by

            “a Pythonscript solution”

            It would be great. I googled but I don’t even know how to start… :/

            Thanks for reply.
            Regards.

            Alan KilbornA 1 Reply Last reply Reply Quote 0
            • Alan KilbornA Offline
              Alan Kilborn @Jesus Campos
              last edited by

              @Jesus-Campos

              So taking a nod from this recent posting, we can tweak what is found there, to obtain:

              # -*- coding: utf-8 -*-
              
              from Npp import editor, notepad, NOTIFICATION, MENUCOMMAND
              
              def callback_npp_FILESAVED(args):
                  for (filename, bufferID, index, view) in notepad.getFiles():
                      if bufferID == args['bufferID']:
                          if filename.endswith('_js.php'):
                              notepad.menuCommand(MENUCOMMAND.LANG_JS)
                          break
              
              notepad.callback(callback_npp_FILESAVED, [NOTIFICATION.FILESAVED])
              

              Which should do what you want.

              1 Reply Last reply Reply Quote 4
              • Jesus CamposJ Offline
                Jesus Campos
                last edited by

                Hi, thanks for the script. It opened a new world to me :)

                I Changed the enumerator [NOTIFICATION.FILESAVED] to [NOTIFICATION.FILEOPENED] and It worked but with a problem: if I do not have any opened file it work well, if I have, it change the language to the first opened file… So, I just added notepad.activateFile(filename) before the menu command and it work ok :)

                Thanks!

                1 Reply Last reply Reply Quote 2

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors