I normally use \t for tab.
Do it is possible to automatically switch to 4 space when edit a .py file?
Python Tab
- Author
- Message
-
Offline
- Posts: 1294
- Joined: Thu Nov 16, 2006 11:53 am
- Location: Kyiv, Ukraine
Re: Python Tab
I think the Tab/Spaces setting is global for all languages and there is no built-in ability to make it different for different languages.
Probably a resident script can help with this. The idea is to analyze the file extension on AKDN_OPENDOCUMENT_FINISH and AKDN_SAVEDOCUMENT_FINISH and set the desired Tab/Spaces setting basing on the file extension. The resident script should subclass AkelPad's main proc similarly to this:
https://github.com/d0vgan/AkelPad-Scrip ... toFocus.js
Then, in the MainCallback, we should process AKDN_OPENDOCUMENT_FINISH (0x436) and AKDN_SAVEDOCUMENT_FINISH (0x438).
To get the file extension, one should call AkelPad.GetEditFile(0) and then extract the extension similarly to getFileExt in https://github.com/d0vgan/AkelPad-Scrip ... s/RunMe.js
Finally, to deal with Tabs/Spaces, probably the field bTabStopAsSpaces of FRAMEDATA should be used. Probably a combination of AKD_GETFRAMEINFO + AKD_SETFRAMEINFO should be used for this.
(By the way, the approach with bTabStopAsSpaces is used in InsertTabOrSpaces.js that can be loaded using the AkelUpdater).
The approach with the resident script looks somewhat complicated, so maybe instead you could create two simple scripts for Tab and Shift+Tab (e.g. Tab.js and ShiftTab.js and assign Tab and Shift+Tab keys to call these scripts). In each of these scripts, you may analyze the file extension and insert/remove either Tab or Space characters.
Probably a resident script can help with this. The idea is to analyze the file extension on AKDN_OPENDOCUMENT_FINISH and AKDN_SAVEDOCUMENT_FINISH and set the desired Tab/Spaces setting basing on the file extension. The resident script should subclass AkelPad's main proc similarly to this:
https://github.com/d0vgan/AkelPad-Scrip ... toFocus.js
Then, in the MainCallback, we should process AKDN_OPENDOCUMENT_FINISH (0x436) and AKDN_SAVEDOCUMENT_FINISH (0x438).
To get the file extension, one should call AkelPad.GetEditFile(0) and then extract the extension similarly to getFileExt in https://github.com/d0vgan/AkelPad-Scrip ... s/RunMe.js
Finally, to deal with Tabs/Spaces, probably the field bTabStopAsSpaces of FRAMEDATA should be used. Probably a combination of AKD_GETFRAMEINFO + AKD_SETFRAMEINFO should be used for this.
(By the way, the approach with bTabStopAsSpaces is used in InsertTabOrSpaces.js that can be loaded using the AkelUpdater).
The approach with the resident script looks somewhat complicated, so maybe instead you could create two simple scripts for Tab and Shift+Tab (e.g. Tab.js and ShiftTab.js and assign Tab and Shift+Tab keys to call these scripts). In each of these scripts, you may analyze the file extension and insert/remove either Tab or Space characters.
-
Offline
- Posts: 1294
- Joined: Thu Nov 16, 2006 11:53 am
- Location: Kyiv, Ukraine
Re: Python Tab
I think something similar to this should work: