Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions memo.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ hide_same_dir=no
# Date format https://www.lua.org/pil/22.1.html
timestamp_format=%Y-%m-%d %H:%M:%S

# Display titles instead of filenames when available
# Display titles instead of filenames when available.
# Can be "yes", "no", or "web".
# "yes" uses titles for all, "no" uses filenames/URLs, "web" uses titles for web entries only (eg. youtube videos).
use_titles=yes

# Truncate titles to n characters, 0 to disable
Expand Down Expand Up @@ -49,4 +51,4 @@ close_binding=LEFT ESC
# Opening the file "/data/TV Shows/Comedy/Curb Your Enthusiasm/S4/E06.mkv" will
# lead to "Curb Your Enthusiasm" to be shown in the directory menu. Opening
# of that entry will then open that file again.
path_prefixes=pattern:.*
path_prefixes=pattern:.*
28 changes: 20 additions & 8 deletions memo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local options = {
timestamp_format = "%Y-%m-%d %H:%M:%S",

-- Display titles instead of filenames when available
use_titles = true,
use_titles = "yes",

-- Truncate titles to n characters, 0 to disable
truncate_titles = 60,
Expand Down Expand Up @@ -187,6 +187,13 @@ local device_protocols = {
dvdnav = true
}

local web_protocols = {
http = true,
https = true,
ytdl = true,
dvb = true
}

function utf8_char_bytes(str, i)
local char_byte = str:byte(i)
local max_bytes = #str - i + 1
Expand Down Expand Up @@ -949,7 +956,11 @@ function show_history(entries, next_page, prev_page, update, return_items)
return
end

if search_words and not options.use_titles then
local is_web = effective_protocol and web_protocols[effective_protocol]
--for this specific entry
local use_titles_effective = options.use_titles == "yes" or options.use_titles == "web" and is_web

if search_words and not use_titles_effective then
for _, word in ipairs(search_words) do
if unaccent(display_path):lower():find(word, 1, true) == nil then
return
Expand Down Expand Up @@ -985,7 +996,7 @@ function show_history(entries, next_page, prev_page, update, return_items)
end
end

if options.hide_deleted and not (search_words and options.use_titles) then
if options.hide_deleted and not (search_words and use_titles_effective) then
if state.known_files[cache_key] and not state.existing_files[cache_key] then
return
end
Expand Down Expand Up @@ -1013,9 +1024,10 @@ function show_history(entries, next_page, prev_page, update, return_items)
end

local title = file_info:sub(1, title_length)
if not options.use_titles then
title = ""
end

if not use_titles_effective then
title = ""
end

if dir_menu then
title = basename
Expand All @@ -1039,15 +1051,15 @@ function show_history(entries, next_page, prev_page, update, return_items)

title = title:gsub("\n", " ")

if search_words and options.use_titles then
if search_words and use_titles_effective then
for _, word in ipairs(search_words) do
if unaccent(title):lower():find(word, 1, true) == nil then
return
end
end
end

if options.hide_deleted and (search_words and options.use_titles) then
if options.hide_deleted and (search_words and use_titles_effective) then
if state.known_files[cache_key] and not state.existing_files[cache_key] then
return
end
Expand Down