option to continue with current encoding when opening corrupted file using OpenFile macro method - emeditor

While opening a partly corrupted file using OpenFile (encoding specified), there isn't an option to force it using the specified encoding, thus the macro is interrupted.
Is there an option in macro to force it "Continue opening as Current Encoding", instead of letting the user choose and continue?

You can clear the Prompt if Null Character Found and Prompt if Invalid Character Found options in the File page of configuration properties of the file type. To do this in a macro, you can add the following code before OpenFile.
document.ConfigName = "Text"; // replace "Text" with the configuration of your file type
cfg = document.Config;
cfg.File.PromptInvalid = false;
cfg.File.PromptNull = false;
cfg.Save();

Related

Xamarin Windows cannot access the specified device, path, or file

I have a Xamarin application running on Windows, and I have a method which includes an opening of a pdf file like this:
var psi = new ProcessStartInfo
{
FileName = "cmd",
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
CreateNoWindow = true,
Arguments = $"/c start {filename}"
};
Process.Start(psi);
When this executes, the windows opens a dialog with the following message:
Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.
The filename is a pdf file located in the LocalApplicationData, and I also have a database there, and the application is normally creating a database there and manipulates with it, so it should have a permission to access that folder. Also, when I run that pdf with double-click outside the application, the pdf opens normally with Chrome. How to solve this?
Unless you have a file there called "cmd" this won't work, as you have declared your filename as a string with the value "cmd".

Neomutt Pipe Attachments to Shell Program from Menu

The header of the attachments menu in neomutt gives the options
q:Exit s:Save |:Pipe p:Print ?:Help
I assumed that the Pipe option would allow me to pipe a chosen attachment to the shell. In particular, maybe I want to open a file in a way that bypasses the mailcap defaults.
Suppose I wanted to open a file from the attachment menu with open. Is there a way to achieve this with Pipe and not by going to edit my mailcap?
Thanks
The only downfall of this is you need to specify all types, because wildcard can be only in subtype - */* or * doesn't work
Store original mailcap file location in a variable
Define macro in attach menu that changes mailcap file to a new one, run view-attach (which uses open to open a file with) and return to original mailcap_path configuration.
~/.muttrc
set my_origmailcap=$mailcap_path
macro attach <Space> "\
<enter-command>set mailcap_path=~/.mailcap2<enter>\
<view-attach>\
<enter-command>set mailcap_path=$my_origmailcap<enter>\
"
~/.mailcap2
audio/* ; open %s
image/* ; open %s
text/* ; open %s
video/* ; open %s

c++ Visual Studio Output file error

I'm creating a text editor for one application, using richtextbox to change the text. I have to add a text file with openfiledialog, then save that file to an output file.
I'm using this code to save my file
SaveFileDialog^ saveFile1 = gcnew SaveFileDialog;
if (saveFile1->ShowDialog() ==
System::Windows::Forms::DialogResult::OK && saveFile1->FileName->Length > 0)
{
// Save the contents of the RichTextBox1 into the file.
richTextBox1->SaveFile(saveFile1->FileName);
}
but the following string is added to my output file
{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 Arial;}}
\viewkind4\uc1\pard\lang1036\fs17
I'd like to remove this from my file, does anyone have a solution?
It looks like the RichTextBox.SaveFile function has a second argument which can be used to specify the format of the file. So instead of calling:
richTextBox1->SaveFile(saveFile1->FileName);
Try calling it like so:
richTextBox1->SaveFile(saveFile1->FileName, RichTextBoxStreamType.PlainText);
And this should save the contents as plain text instead of rich text.

Qt4 - QDir::entryList() doesn't return files/dirs with invalid encoding

My Qt4-based application (http://qcomicbook.linux-projects.net) has a problem with opening files located in directories with invalid encoding (most likely koi-8 encoding, or some other Asian encoding). The problem occurs in the following piece of code:
QDir dir(path);
dir.setSorting(flags);
dir.setFilter(QDir::AllDirs|QDir::Files);
const QStringList files = dir.entryList();
foreach (QString f, files) {
...
}
If path includes dirs/files with invalid encoding, then dir.entryList() just filters them out. The problem is also indicated by QFileDialog::getExistingDirectory dialog which displays "invalid encoding" warning along file dir names.
Is there any workaround for this, ideally transparent to the end user?

Automatically restore last session in Gvim

I installed sessionman, and it works fine. But I lose session when reload the X session twice (logout/login, reboot, etc), because when KDE restores Gvim, it does not load session automatically, but only last file, and then saves this under the last session name on next reload. If I did not run SessionOpen then on next reload my last session is lost.
I configured session autosave already. It would be nice if Gvim can load last session automatically too. However, this feature does not work for me even manually. When I restart Gvim, SessionShowLast prints "Last session is undefined, current session is """.
The sessionman documentation says: "The name of an opened session is saved in g:LAST_SESSION variable which is saved in the viminfo file if 'viminfo' option contains '!'". But I have not found any clear explanation what is "viminfo option", where it should contain '!', and how do I set it. Also I'm not sure how to execute SessionOpenLast from vimrc.
If the way I'm trying to fix the problem is wrong then please correct me.
viminfo is a variable that describes what data should be stored in the viminfo file.
For full details, run :help 'viminfo' (note the quotes) in vim:
! When included, save and restore global variables that start
with an uppercase letter, and don't contain a lowercase
letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis"
and "_K_L_M" are not. Nested List and Dict items may not be
read back correctly, you end up with a string representation
instead.
Use :set viminfo to see the current value of your viminfo setting. Modify it in your ~/.vimrc file.
set viminfo='100,<500,s10,h,!
Because vimrc is loaded before plugins, adding SessionOpenLast to vimrc will not work. To solve this, create an auto-command:
autocmd VimEnter * SessionOpenLast
"My Sessionman Conf
set viminfo='100,<500,s10,h,!
let sessionman_save_on_exit = 1
function! ReadSession()
SessionOpenLast
endfunction
" if no file args then open the last session
autocmd VimEnter * if argc() == 0 | call ReadSession() | endif

Resources