sublime - how to save file on close automatically - editor

How do I configure Sublime 2 to save files automatically that I close? It should behave like, User opens file, makes edits, closes file, and the edits are automatically saved even though the user did not manually save the edited file.
This is close, but I want it to save on file close rather than lose focus.
https://docs.sublimetext.io/reference/settings.html
save_on_focus_lost

Do you want the file to be magically saved when just one is closed or when all your opened files (window) are closed? In the first case I suggest to open each file into a different window of SublimeText2.
In the second scenario you're looking for hot_exit : Preferences.sublime-settings
// Exiting the application with hot_exit enabled will cause it to close
// immediately without prompting. Unsaved modifications and open files will
// be preserved and restored when next starting.
//
// Closing a window with an associated project will also close the window
// without prompting, preserving unsaved changes in the workspace file
// alongside the project.
"hot_exit": true,
In addition to remember_open_files you can save automatically on exit and choose whether or not those files are opened next time.

Related

How to download multiple files one after another

I have a ajax download functionality in my MVC webapp.
User can select a criteria and click on export button. Internally it will fetch data and return an Excel file. up to this functionality is working fine.
But the issue occurs, While one download process is running and now user changes the filter criteria and again click on export button. Now two download processes are running. Whichever process completes first will return file to download. Now the user can see Open, save, cancel option to download first file. As this stage when second download request is also completed and returns file to download. When I opens one file the another file download option is also lost.
Initially I thought it might because both the files are having same name. So I made changes to set unique file name for every request. But It still gives only single file to download.
Can anyone help me on this?
edited :
On other pages where I have two different types of files to download, the above functionality works successfully.
In none ajax requests, page can only be waiting for one response.
In order to solve that problem and wait for multiple responses you should use target attribute with value "new" as the following code depicts:
Your download Text
The above code makes each response to be downloaded in a new tab.

Deleting 20000 files in applicationWillTerminate

In my iPhone app, I am downloading files from server and storing them locally (user's document directory). The path of each file downloaded is subsequently updated in database.
If user tries to delete a file, first the file is deleted from local path using removeItemAtPath: (NSFileManager), then corresponding record is deleted from database.
Now I have one of the requirements according to which user can turn on a UISwitch to delete all data on app exit.
Now my question is -
suppose user downloaded 20000 files, say small images, and user turned
on the switch to delete all data on app exit. Is it good to handle
this task in applicationWillTerminate? What is the best way to
accomplish this scenario?
Please suggest.
Don't delete the files individually, delete and recreate the folder.
Your database could be handled differently by version tagging so that you can batch delete the items on the next run.
applicationWillTerminate will only be called if your app goes background (the only option by pressing Home button of the device) and "Application does not run in background" key is set in your app's info.plist file to "YES". Otherwise it won't ever be called.
If you are planning deploy app with similar functionality, you can use applicationWillTerminate for removing so many files. However, I would never recommend you that. Instead, my recommendation is to remove the files as soon as they are processed, if possible at all.
Another thing you must consider is not to save so many files in Document directory, however small those are. Document directory is backed up by iTunes and iCloud and if you store so many files there, you are gonna possibly violate Apple's Data Storage Guideline that would reject your app from App Store. It is always a good idea to store transient files in application's "tmp" directory and delete them when not required anymore.

Get file name of file used to open the associated application

I want to write a small app that does some data manipulation on the contents of a simple text file.
I just want to be able to right click such a file, choose 'Open with' in Windows, select my app, then the app opens, parses the file, does some stuff and closes immediately again.
Question: when my app starts, how do I get the file name that triggered the app to start?
Thanks!
You get the file as parameter number 1.
You can get it with the function ParamStr(1).
Have a look here for more details:
http://www.delphibasics.co.uk/RTL.asp?Name=ParamStr
For your information, ParamStr(0) is the filename (including complete path) of your EXE application.

How can I close an app without a modal dialog box being shown?

I have an app that can optionally open PDF's after it creates them. If two reports are generated in succession with the same name, the second attempt fails if the first copy of acrobat still has the PDF open, so before I write the PDF I check (with FindWindow) for a window with the document name. If one is found I issue a SendMessage WM_Close.
This works OK, but I was doing some other tests and was using Word to "edit" the PDF, to hold it open so I could test the app's behaviour when it can't write the PDF file. Now, when my app tries to close the window, Word pops up a "do you want to save" dialog. If I click cancel, Word remains open, my app carries on and I can test that it behaves sensibly when it encounters a file that it can't write to.
All good, but it has alerted me to the fact that using SendMessage WM_CLOSE to close another app will snag my app if the other app pops up a modal dialog. Is there any way around this - i.e a more forceful (but not too forceful) way of closing the other app? Or a "Close and click on cancel if necessary". Or should I use asynchronous messages?
Do not force any application to close, there may be other documents open the user is viewing etc... You can use SendMessageTimeout to wait the return of WM_CLOSE a sensible amount of time, and then proceed with either failure or success..
var
Word: HWND;
msgResult: DWORD;
begin
...
SendMessageTimeout(Word, WM_CLOSE, 0, 0, SMTO_NORMAL, 5000, msgResult);
if IsWindow(Word) then begin
// bummer! Application is open...
 
I would not close the other application at all. I think it's better to delete the current file before generating the report. If it fails (DeleteFile), show a message to the user that the file cannot be overwritten (because it is opened by another program) and do not generate the report at all. This is much safer, because you leave the option to the user. Also this saves you from major headaches, what if the program is opened by another program that does not show the title in the window caption?
If you want to go one step further than WM_CLOSE you can only terminate the application. Everything else would be like lottery.
That said I am against both. What if your PDF opens in a MDI application already showing other documents? Forcing the application to close would make the user lose all changes to the other open documents. And sending a close message to this application would be annoying since the user still needs the other documents opened.
You cannot predict the behavior of every application. And you certainly don't know every application. If the report has the same name then you can tell the user to close the other one with the same name. Otherwise he won't get a new report. Think what would happen if Windows started closing your applications as soon as you try to overwrite a file which is currently in use.

Actionscript downloading a File using FileReference

I'm having trouble working on FileReference download(URL) function. I needed to automatically download the files in a particular space on my harddisk but the SAVE AS dialog always displays. can I make it automatically download in a certain place on my disk?
I'm going to assume "automatically download" means "save" here. Nope, If you use FileReference (or File in AIR), there's no way to automatically save without showing the Save As dialog box.
If you don't need to access the file outside of the app, then take a look at the SharedObject class: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/SharedObject.html. By default you can create SharedObjects of up to 100KB without needing the client's permission (see the description of getLocal()), which should be fine for more simple text or xml info - you can compress it using ByteArray if you want to save space. Any more than that and a small dialog will open asking permission. Once you've given permission however, it won't ask again.

Resources