Add textunknownasplain configuration variable to tell the indexer to process text/xxx where xxx is unknown as text/plain
This commit is contained in:
parent
34003390f2
commit
78183a8e00
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2004 J.F.Dockes
|
/* Copyright (C) 2004-2022 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -33,14 +33,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <list>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <iterator>
|
|
||||||
|
|
||||||
#include "cstr.h"
|
#include "cstr.h"
|
||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
@ -854,6 +851,13 @@ string RclConfig::getMimeHandlerDef(const string &mtype, bool filtertypes, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!mimeconf->get(mtype, hs, "index")) {
|
if (!mimeconf->get(mtype, hs, "index")) {
|
||||||
|
if (mtype.find("text/") == 0) {
|
||||||
|
bool alltext{false};
|
||||||
|
getConfParam("textunknownasplain", &alltext);
|
||||||
|
if (alltext && mimeconf->get("text/plain", hs, "index")) {
|
||||||
|
return hs;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (mtype != "inode/directory") {
|
if (mtype != "inode/directory") {
|
||||||
IdxDiags::theDiags().record(IdxDiags::NoHandler, fn, mtype);
|
IdxDiags::theDiags().record(IdxDiags::NoHandler, fn, mtype);
|
||||||
LOGDEB1("getMimeHandlerDef: no handler for '" << mtype << "' (fn " << fn << ")\n");
|
LOGDEB1("getMimeHandlerDef: no handler for '" << mtype << "' (fn " << fn << ")\n");
|
||||||
@ -1233,6 +1237,16 @@ string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag, bo
|
|||||||
|
|
||||||
if (apptag.empty() || !mimeview->get(mtype + string("|") + apptag, hs, "view"))
|
if (apptag.empty() || !mimeview->get(mtype + string("|") + apptag, hs, "view"))
|
||||||
mimeview->get(mtype, hs, "view");
|
mimeview->get(mtype, hs, "view");
|
||||||
|
|
||||||
|
// Last try for text/xxx if alltext is set
|
||||||
|
if (hs.empty() && mtype.find("text/") == 0 && mtype != "text/plain") {
|
||||||
|
bool alltext{false};
|
||||||
|
getConfParam("textunknownasplain", &alltext);
|
||||||
|
if (alltext) {
|
||||||
|
return getMimeViewerDef("text/plain", apptag, useall);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return hs;
|
return hs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1425,7 +1439,7 @@ string RclConfig::getPidfile() const
|
|||||||
#endif // ! _WIN32
|
#endif // ! _WIN32
|
||||||
|
|
||||||
fn = path_cat(getCacheDir(), "index.pid");
|
fn = path_cat(getCacheDir(), "index.pid");
|
||||||
out:
|
out:
|
||||||
LOGINF("RclConfig: pid/lock file: " << fn << "\n");
|
LOGINF("RclConfig: pid/lock file: " << fn << "\n");
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
|
|||||||
@ -178,11 +178,12 @@ static RecollFilter *mhFactory(RclConfig *config, const string &mimeOrParams,
|
|||||||
MD5String("MimeHandlerNull", id);
|
MD5String("MimeHandlerNull", id);
|
||||||
return nobuild ? 0 : new MimeHandlerNull(config, id);
|
return nobuild ? 0 : new MimeHandlerNull(config, id);
|
||||||
} else if (lmime.find("text/") == 0) {
|
} else if (lmime.find("text/") == 0) {
|
||||||
// Try to handle unknown text/xx as text/plain. This
|
// Try to handle unknown text/xx as text/plain. This only happen if the text/xx was defined
|
||||||
// only happen if the text/xx was defined as "internal" in
|
// as "internal" in mimeconf.
|
||||||
// mimeconf, not at random. For programs, for example this
|
// This is historic, because the natural way with the current code would be to specify
|
||||||
// allows indexing and previewing as text/plain (no filter
|
// "internal text/plain" instead of just "internal"...
|
||||||
// exec) but still opening with a specific editor.
|
// Also see rclconfig for the textunknownisplain configuration variable which allows
|
||||||
|
// processing all unknown text/* as text/plain.
|
||||||
LOGDEB2("mhFactory(" << lmime << "): returning MimeHandlerText(x)\n");
|
LOGDEB2("mhFactory(" << lmime << "): returning MimeHandlerText(x)\n");
|
||||||
MD5String("MimeHandlerText", id);
|
MD5String("MimeHandlerText", id);
|
||||||
return nobuild ? 0 : new MimeHandlerText(config, id);
|
return nobuild ? 0 : new MimeHandlerText(config, id);
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
.bas = text/plain
|
.bas = text/plain
|
||||||
.cpp = text/x-c
|
.cpp = text/x-c
|
||||||
.h = text/x-c
|
.h = text/x-c
|
||||||
|
.hpp = text/x-c++
|
||||||
.c = text/x-c
|
.c = text/x-c
|
||||||
.cc = text/x-c
|
.cc = text/x-c
|
||||||
.cxx = text/x-c
|
.cxx = text/x-c
|
||||||
|
|||||||
@ -15,8 +15,7 @@
|
|||||||
# quoted with "double quotes". Double quotes processing is NOT applied to single value parameter,
|
# quoted with "double quotes". Double quotes processing is NOT applied to single value parameter,
|
||||||
# and using quotes there will result in bad values.
|
# and using quotes there will result in bad values.
|
||||||
|
|
||||||
# <grouptitle id="WHATDOCS">Parameters affecting what documents we
|
# <grouptitle id="WHATDOCS">Parameters affecting what documents we index</grouptitle>
|
||||||
# index</grouptitle>
|
|
||||||
|
|
||||||
# <var name="topdirs" type="string"><brief>Space-separated list of files or
|
# <var name="topdirs" type="string"><brief>Space-separated list of files or
|
||||||
# directories to recursively index.</brief><descr>Default to ~ (indexes
|
# directories to recursively index.</brief><descr>Default to ~ (indexes
|
||||||
@ -227,6 +226,15 @@ compressedfilemaxkbs = 100000
|
|||||||
# disable.</descr></var>
|
# disable.</descr></var>
|
||||||
textfilemaxmbs = 20
|
textfilemaxmbs = 20
|
||||||
|
|
||||||
|
# <var name="textunknownasplain" type="bool">
|
||||||
|
# <brief>Process unknown text/xxx files as text/plain</brief>
|
||||||
|
# <descr>Allows indexing misc. text files identified as text/whatever by 'file' or 'xdg-mime'
|
||||||
|
# without having to explicitely set config entries for them. This works fine for indexing (but will
|
||||||
|
# cause processing of a lot of garbage though), but the documents indexed this way will be opened by
|
||||||
|
# the desktop viewer, even if text/plain has a specific editor.</descr>
|
||||||
|
# </var>
|
||||||
|
#textunknownasplain=0
|
||||||
|
|
||||||
# <var name="indexallfilenames" type="bool"><brief>Index the file names of
|
# <var name="indexallfilenames" type="bool"><brief>Index the file names of
|
||||||
# unprocessed files</brief><descr>Index the names of files the contents of
|
# unprocessed files</brief><descr>Index the names of files the contents of
|
||||||
# which we don't index because of an excluded or unsupported MIME
|
# which we don't index because of an excluded or unsupported MIME
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user