emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [External] : [emacs bookmark.el] Sorting by last set


From: Drew Adams
Subject: RE: [External] : [emacs bookmark.el] Sorting by last set
Date: Wed, 25 May 2022 05:05:31 +0000

> >> Yes I've seen this comment in bookmark.el. It seems that it
> >> should not be taken lightly. So this rules out adding a
> >> "modified date" field (my 2nd option) but maybe my first
> >> option (sorting 'bookmark-alist' in last modified order by 
> >> default) is still possible.
> >
> >Extending the bookmark format (by adding more fields) is totally
> >possible.
> >
> >I think sorting by last set sounds like a nice feature -- patches
> >welcome.
> 
> I agree.  Extending the format to add fields like 'created-date'
> and/or 'last-modified' date seems fine to me, to support features
> like this.
> 
> In fact, when I was reviewing and applying Manuel's recent changes
> to toggle sorting in the bookmark menu buffer, I was already
> thinking that this would all be easier if the bookmark itself
> carried its creation date.
> 
> Drew, correct me if my guess is wrong, but does your objection
> (earlier in this thread) to extending the bookmark file format
> stem from the fact that long ago there was at least one -- maybe
> more? -- format revision that was not done in a compatible way?
> (I think it may have been my fault, too, but it's too long ago for
> me to remember clearly.)
> 
> Anyway, we fixed things and nowadays the format is quite easily
> extensible in a backwards-compatible way.  The PARAM-ALIST
> component of each bookmark object is just an alist with a known
> set key/value pairs.  If we add a new pair, old versions of
> bookmark.el will just ignore it while new versions will make use
> of it.
> 
> If you have some other reason for objecting to extending the
> format, though, please say.


Anyone (app, user), anywhere, can of course add
any fields, for any kind of bookmark.

I'd rather that nothing depend on the existence
of some new "standard" fields.  Adding "standard"
fields is likely to result in such dependencies
or expectations.  That's my concern.

I don't feel strongly about this.  But in general,
I expect that the fewer "standard" fields vanilla
Emacs adds, the less chance of breakage.
___

That said, nothing I say will change anything,
I expect.  And if such a dependency breaks
something then I'll just have to deal with that
when it happens.
___

As for this particular proposed addition: I
haven't seen the need for a last-modified field,
and I've never had anyone ask for it or point
out its utility.

I don't recall whether I at one point considered
it.  But yes, such a field is not uncommon for
metadata of various sorts (e.g. file attributes).

But was there any particular use case mentioned?
Was it requested to solve some problem?  If so,
I missed that.

The request seemed to be only to be able to sort
by such a field.  How about a reason why such a
sort is requested/useful?  I'm not claiming it
can't be useful; I'm asking what its use is.

I can imagine it might sometime be useful to
know when a particular bookmark was last
modified.  But that would likely be for some
forensic reason (for me): when/why/how was that
bookmark last changed?  A bit like checking a
history when looking for the cause of a problem.

But sorting all bookmarks by last-modified time?
How is that useful?  (Again, just curious; not
claiming it's not useful.)
___

What I do know is useful, however, is the time
(date) of last visit/access (as well as time of
creation, of course).  That's related to the
number of times a bookmark has been visited
(accessed).

Sorting by visit time is like seeing a recentf
list.  Sorting by number of visits is like 
seeing your favorites list.  I often want to
sort these ways.
___

Now you may say that `ls' sorts by last mod
time as one of its main sort orders.  And I
agree that that order is very useful.  I'm
not (yet) convinced the same is true for
bookmarks, but I guess there's some similarity.

(Even for files, I think that most of my uses
of `ls' sorting by date would be handled just
as well if the date were last access instead
of last mod.)
___

Bookmark+ has a `created' field, for the time
(date) of creation.  I'd of course prefer, if
you add this, that you use the same field
name: `created' instead of `created-date'.
(One less thing to work around.)
___

Bookmark+'s version of `C-h v bookmark-alist':


Current list of bookmarks (bookmark records).
Bookmark functions update the value automatically.
You probably do not want to change the value yourself.

The value is an alist with entries of the form
 (BOOKMARK-NAME . PARAM-ALIST)
or the deprecated form (BOOKMARK-NAME PARAM-ALIST).

 BOOKMARK-NAME is the name you gave to the bookmark when creating it.
 PARAM-ALIST is an alist of bookmark data.  The order of the entries
  in PARAM-ALIST is not important.  The possible entries are described
  below.

Bookmarks created using vanilla Emacs (`bookmark.el'):

 (filename . FILENAME)
 (location . LOCATION)
 (position . POS)
 (front-context-string . STR-AFTER-POS)
 (rear-context-string  . STR-BEFORE-POS)
 (handler . HANDLER)
 (annotation . ANNOTATION)

 FILENAME names the bookmarked file.
 LOCATION names the bookmarked file, URL, or other place (Emacs 23+).
  FILENAME or LOCATION is what is shown in the bookmark list
  (`C-x r l') when you use `M-t'.
 POS is the bookmarked buffer position (position in the file).
 STR-AFTER-POS is buffer text that immediately follows POS.
 STR-BEFORE-POS is buffer text that immediately precedes POS.
 ANNOTATION is a string that you can provide to identify the bookmark.
  See options `bookmark-use-annotations' and
  `bookmark-automatically-show-annotations'.
 HANDLER is a function that provides the bookmark-jump behavior
  for a specific kind of bookmark.  This is the case for Info
  bookmarks, for instance (starting with Emacs 23).

Bookmarks created using Bookmark+ are the same as for vanilla Emacs,
except for the following differences.

1. Time of creation is recorded when you create a new bookmark:

 (created . CREATION-TIME)

 CREATION-TIME is an Emacs time representation, returned by function
 `current-time'.

2. Visit information is recorded, using entries `visits' and `time':

 (visits . NUMBER-OF-VISITS)
 (time . TIME-LAST-VISITED)

 NUMBER-OF-VISITS is a whole-number counter.

 TIME-LAST-VISITED is an Emacs time representation, returned by
 `current-time'.

3. The buffer name is recorded, using entry `buffer-name'.  It need
not be associated with a file.

4. If no file is associated with the bookmark, then FILENAME is
   `   - no file -'.

5. Bookmarks can be tagged by users.  The tag information is recorded
using entry `tags':

 (tags . TAGS-ALIST)

 TAGS-ALIST is an alist with string keys.

6. A bookmark can be simply a wrapper for a file, in which case it has
entry `file-handler' instead of `handler'.  When you "jump" to such
a bookmark, the `file-handler' function or shell-command is applied to
the `filename' entry.  Any `handler' entry present is ignored, as are
entries such as `position'.  It is only the target file that is
important.

7. Bookmarks can have individual highlighting, provided by users.
This overrides any default highlighting.

 (lighting . HIGHLIGHTING)

 HIGHLIGHTING is a property list that contain any of these keyword
 pairs:

   `:style' - Highlighting style.  Cdrs of `bmkp-light-styles-alist'
              entries are the possible values.
   `:face'  - Highlighting face, a symbol.
   `:when'  - A sexp to be evaluated.  Return value of `:no-light'
              means do not highlight.

8. The following additional entries are used to record region
information.  When a region is bookmarked, POS represents the region
start position.

 (end-position . END-POS)
 (front-context-region-string . STR-BEFORE-END-POS)
 (rear-context-region-string . STR-AFTER-END-POS))

 END-POS is the region end position.
 STR-BEFORE-END-POS is buffer text that precedes END-POS.
 STR-AFTER-END-POS is buffer text that follows END-POS.

The two context region strings are non-nil only when a region is
bookmarked.

 NOTE: The relative locations of `front-context-region-string' and
 `rear-context-region-string' are reversed from those of
 `front-context-string' and `rear-context-string'.  For example,
 `front-context-string' is the text that *follows* `position', but
 `front-context-region-string' *precedes* `end-position'.

9. The following additional entries are used for a Dired bookmark.

 (dired-marked . MARKED-FILES)
 (dired-subdirs . INSERTED-SUBDIRS)
 (dired-hidden-dirs . HIDDEN-SUBDIRS)
 (dired-switches . SWITCHES)

 MARKED-FILES is the list of files that were marked `*'.
 INSERTED-SUBDIRS is the list of subdirectores that were inserted.
 HIDDEN-SUBDIRS is the list of inserted subdirs that were hidden.
 SWITCHES is the string of `dired-listing-switches'.

10. The following additional entries are used for a Gnus bookmark.

 (group . GNUS-GROUP-NAME)
 (article . GNUS-ARTICLE-NUMBER)
 (message-id . GNUS-MESSAGE-ID)

 GNUS-GROUP-NAME is the name of a Gnus group.
 GNUS-ARTICLE-NUMBER is the number of a Gnus article.
 GNUS-MESSAGE-ID is the identifier of a Gnus message.

11. For a URL bookmark, FILENAME or LOCATION is a URL.

12. A sequence bookmark has this additional entry:

 (sequence . COMPONENT-BOOKMARKS)

 COMPONENT-BOOKMARKS is the list of component bookmark names.

13. A function bookmark has this additional entry, which records the
FUNCTION:

 (function . FUNCTION)

14. A bookmark-list bookmark has this additional entry, which records
the state of buffer `*Bookmark List*' at the time it is created:

 (bookmark-list . STATE)

 STATE records the sort order, filter function, omit list, and title.
___

HTH.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]