Mercurial > emacs
view lisp/mh-e/mh-seq.el @ 105973:b7d8222914b4
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-clone-subtree-with-time-shift): Make it work at the
end of the buffer.
* org-mobile.el (org-mobile-write-checksums): Specify coding
system.
(org-mobile-timestamp-buffer): Keep local variable/mode line at
beginning of buffer.
* org-latex.el (org-latex-entities-regexp): Fix typo in regexp.
* org.el (org-block-todo-from-children-or-siblings-or-parent)
(org-block-todo-from-checkboxes): Do not block changes to a nil
TODO state.
2009-11-13 James TD Smith <ahktenzero@mohorovi.cc>
* org-habit.el (org-habit-parse-todo): Indicate which habit is
wrongly set up in the error messages.
* org-colview.el (org-columns-display-here): Don't try to
calculate values if the underlying property is not set.
(org-columns-string-to-number): Convert age strings back into
fractional days.
(org-agenda-colview-summarize): Handle extended summary types
properly.
* org-colview-xemacs.el (org-columns-display-here): Don't try to
calculate values if the underlying property is not set.
(org-columns-string-to-number): Convert age strings back into
fractional days.
(org-agenda-colview-summarize): Handle extended summary types
properly.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-format-drawer-function): New variable.
(org-export-format-drawer): New function.
(org-export-preprocess-string): Pass the backend as a parameter to
`org-export-remove-or-extract-drawers'.
(org-export-remove-or-extract-drawers): New parameter BACKEND.
* org-protocol.el (org-protocol-char-to-string): New defsubst.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-diary-entry-in-org-file): Add error
message when no block is selected.
* org-latex.el (org-export-latex-links): Check for protectedness
in the last matched character, not after the match.
* org-datetree.el (org-datetree-find-date-create): Respect
restriction when KEEP-RESTRICTION is set.
(org-datetree-file-entry-under): New function.
(org-datetree-cleanup): New command.
2009-11-13 Dan Davison <davison@stats.ox.ac.uk>
* org-src.el (org-edit-src-code): New optional argument context
allows calling functions to avoid altering the saved window
configuration.
(org-edit-src-exit): Do not restore window configuration when this
function is used in the context of saving the edit buffer.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-out, org-clock-cancel): Revert to
instances to switching to with-current-buffer, because these seem
to cause problems - no idea why.
* org-agenda.el (org-agenda-add-entry-to-org-agenda-diary-file):
Require diary-lib for (diary-date-display-form).
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-log-reschedule, org-log-redeadline): New options.
(org-log-note-headings): Add templates for rescheduling and
deadline changing.
(org-startup-options): Add in-buffer settings for logging changing
schedule and deadline time stamps.
(org-deadline, org-schedule): Check for existing date and arrange
for logging if the user requests it.
(org-add-log-note): Prepare proper note buffers for rescheduling
and deadline changes.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-diary-entry-in-org-file)
(org-agenda-add-entry-to-org-agenda-diary-file)
(org-agenda-insert-diary-make-new-entry): New functions.
(org-agenda-diary-entry): Call
`org-agenda-diary-entry-in-org-file' when appropriate.
* org.el (org-calendar-insert-diary-entry-key): New option.
(org-agenda-diary-file): New option.
("calendar"): Install our insertion function in the calendar.
* org-remember.el (org-datetree): Require.
(org-remember-templates): Add new positioning option.
(org-remember-reference-date): New variable.
(org-remember-apply-template): Store the reference date in a local
variable.
(org-remember-handler): Implement date tree positioning of entries.
* org-datetree.el: New file.
* org-latex.el (org-export-latex-preprocess): Protect targets in
verbatim emphasis.
* org-html.el (org-export-as-html): Protect targets in verbatim
emphasis.
* org-docbook.el (org-export-as-docbook): Protect targets in
verbatim emphasis.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-show-notification): Handle messages that
contain a percent character.
* org-remember.el (org-remember-apply-template): Turn of partial
completion.
* org-mobile.el (org-mobile-before-process-capture-hook): New hook.
(org-mobile-pull): Run `org-mobile-before-process-capture-hook'.
* org.el (org-indent-mode): Define variable already in org.el.
(org-unfontify-region): Remove line-prefix and wrap-prefix
properties only if org-indent-mode is active.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-icalendar.el (org-print-icalendar-entries): Save match data
around call to verify function.
(org-print-icalendar-entries): Add a call to the verification
function.
* org.el (org-speedbar-set-agenda-restriction): Remove unnecessary
save-restrivtion' form.
2009-11-13 Dan Davison <davison@stats.ox.ac.uk>
* org-exp.el (org-export-format-source-code-or-example): restrict
scope of preserve-indentp to the let binding.
(org-src): require org-src, since org-src-preserve-indentation is used.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-timer.el (org-timer-set-timer): Set variables
org-timer-timer[123] correctly.
* org-mobile.el (org-mobile-files-alist): Make it work when
`agenda-archives' is included in
`org-agenda-text-search-extra-files'.
(org-mobile-push): Restore agenda after mobile push.
2009-11-13 John Wiegley <jwiegley@gmail.com>
* org-clock.el (org-resolve-clocks-if-idle): Another fix to the
way the amount of idle time is presented in the minibuffer.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-icalendar.el (org-print-icalendar-entries): Use
org-icalendar-verify-function only if non-nil.
* org.el (org-refile): Refile to clock only if the prefix arg is
2.
(org-sparse-tree): Fix docstring to be in line with prompt.
(org-update-parent-todo-statistics): Call
`org-after-todo-statistics-hook' on each level.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-remember.el (org-remember-apply-template): Make sure the
buffer exists.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-tab-ind-state): New variable.
(org-cycle-level): New function.
(org-cycle-level-after-item/entry-creation): New option.
(org-flag-subtree): New function.
(org-hide-archived-subtrees): Call `org-flag-subtree'.
(org-set-effort): Indexed access.
* org-list.el (org-cycle-item-indentation): New function.
* org.el (org-refile): Make prefix argument 2 refile to current
clock.
(org-priority): Interpret action `remove' as call to remove the
priority cookie.
* org-remember.el (org-remember-apply-template): Don't depend on
buffer name being like file name.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-play-sound): Expand file in
org-clock-sound, to allow ~ for home.
* org-remember.el (org-remember-handler): Set
text-before-node-creation even if this already looks like a node,
because the string might be needed on non-org-mode target files.
* org-agenda.el (org-agenda-open-link): Make this work in agenda
clocktables.
(org-agenda-switch-to): Follow a link at point if
org-return-follows-link' is set and there is nothing else to do in
this line.
2009-11-13 James TD Smith <ahktenzero@mohorovi.cc>
* org-colview-xemacs.el: Add in changes from org-colview.el
2009-11-13 Dan Davison <davison@stats.ox.ac.uk>
* org-exp-blocks.el: Modify split separator regexp to avoid empty
strings.
2009-11-13 James TD Smith <ahktenzero@mohorovi.cc>
* org-colview.el (org-columns-new): Make this work with the new
operators.
(org-columns-store-format): Make this work with the new operators.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-src.el (org-src-preserve-indentation): Document that this
variable is also used during export.
* org-exp.el (org-export-format-source-code-or-example): Preserve
indentation if a block has a -i option, or if
`org-src-preserve-indentation' is set.
* org-exp-blocks.el (org-export-blocks-preprocess): Preserve
indentation if a block has a -i option, or if
`org-src-preserve-indentation' is set.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-mode-map): Define the new archiving keys.
(org-speed-commands-default): Define an archiving key in the speed
command map.
(org-org-menu): Improve the menu structure concerning archiving.
* org-archive.el (org-archive-subtree-default-with-confirmation):
New command.
* org-agenda.el (org-agenda-mode-map): Define the new archiving keys.
(org-agenda-menu): Add the new archiving commands to the menu.
(org-agenda-archive-default)
(org-agenda-archive-default-with-confirmation): New commands.
(org-agenda-archive, org-agenda-archive-to-archive-sibling): Just
call `org-agenda-archive-with'.
(org-agenda-archive-with): New function.
* org-table.el (org-table-convert-region): Inert spaces around "|"
to avoid line beginnings like "|-1" which will be mistaken as
hlines.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-offer-links-in-entry): Return nil if there are no
links, t if a link has been selected.
(org-open-at-point): Open attachment directory when called in the
headline and there are no links in the entry body.
(org-speed-commands-default): Add "o" for open-at-point as a speed
command.
* org-attach.el (org-attach-reveal): Optional prefix arg
IF-EXISTS, which avoids creating the attachment directory if it
does not yet exist.
* org-agenda.el (org-agenda, org-run-agenda-series): Evaluate
MATCH.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el ("abbrev"): Work with abbrev tables only after they have
been loaded.
* org-list.el (org-list-send-list): Fix bug related to match
data.
* org-latex.el (org-export-latex-fontify): Apply verbatim
emphasis.
(org-export-latex-make-header): Insert \obeylines if line breaks
should be preserved.
* org-exp.el (org-export-protect-verbatim): Add an
`org-verbatim-emph' property to such text.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-icalendar.el (org-icalendar-use-plain-timestamp): New option.
(org-print-icalendar-entries): Skip entries where the timestamp is
not a deadline and not scheduled, if the user requests that.
* org-latex.el (org-export-latex-quotation-marks): Allow a bracket
before an opening quote.
* org-archive.el (org-archive-subtree): Keep archive after
archiving something.
* org-id.el (org-id-update-id-locations): Add archive files if
that is required by `org-id-extra-files'.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-src.el (org-src-window-setup): New option.
(org-src-switch-to-buffer): New function.
(org-edit-src-exit): Add optional argument CONTEXT and use it to
restore window configuration.
(org-edit-src-code, org-edit-src-continue, org-edit-src-exit):
Call `org-src-switch-to-buffer'.
* org.el (org-default-properties): Add STYLE property.
(org-files-list): Use the function call to get the files.
(org-additional-option-like-keywords): Add SETUPFILE to completion
list.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-table.el (org-table-convert-region): Correctly interpret
quoting in csv import.
* org.el (org-icompleting-read): Make iswitchb completion work
with lists and tables.
* org-agenda.el (org-agenda-add-entry-text): Never add entry text
while pushing the mobile agenda.
2009-11-13 John Wiegley <jwiegley@gmail.com>
* org-clock.el
(org-clock-auto-clock-resolution): Now takes three values: nil, t
and `when-no-clock-is-running'.
(org-clock-in): Use `org-clock-auto-clock-resolution' to determine
whether or not to resolve Org buffers on clock in.
2009-11-13 James TD Smith <ahktenzero@mohorovi.cc>
* org-colview.el (org-format-time-period): Function to format
times in fractional days for display.
(org-columns-display-here): Add support for showing a calculated
value in place of the property.
(org-columns): Set `org-columns-time' to the current time so time
difference calculations will work.
(org-columns-time): Use to store the current time when column view
is displayed, so all time differences will use the same reference
point.
(org-columns-compile-map): There is now an extra position in each
entry specifying the function to use to calculate the displayed
value for the non-calculated properties in the column,
(org-columns-compute-all): Set `org-columns-time' to the current
time so time difference calculations will work.
(org-columns-compute): Handle column operators where the values
used are calculated from the underlying property.
(org-columns-number-to-string): Handle the 'age' column format
(org-columns-string-to-number): Correct the function name (was
org-column...). Add support for the 'age' column format.
(org-columns-compile-format): Support the additional parameter in
org-columns-compile-map.
2009-11-13 Bastien Guerry <bzg@altern.org>
* org.el (org-mode-hook): Turn `org-mode-hook' into a customizable
variable.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-has-been-used): New variable.
(org-clock-in): Set `org-clock-has-been-used'.
(org-clock-save): Save only if clock data has been used or created
during this session.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-persist): New value, to store only the
clock history.
(org-clock-save): Don't save the clock if only the history should
be stored.
(org-clock-load): Turn off John Wiegley's auto resolving mechanism
when restoring a saved clock.
2009-11-13 John Wiegley <jwiegley@gmail.com>
* org-clock.el (org-clock-display, org-clock-put-overlay): Use
`org-time-clock-use-fractional'.
* org.el (org-time-clocksum-use-fractional)
(org-time-clocksum-fractional-format): Two new customizable
variables which allow the user to select fractional times (1.25
instead of 1:25) in the `org-clock-display' report.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-ascii.el (org-export-ascii-table-keep-all-vertical-lines):
New option.
* org.el (org-tag-alist): Fix customization type.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-mobile.el (org-mobile-update-checksum-for-capture-file):
Make sure the regexp search can fail without throwing an error.
(org-mobile-apply): Save the inbox buffer after removing
successfully applied changes.
2009-11-13 John Wiegley <jwiegley@gmail.com>
* org-clock.el (org-resolve-clocks-if-idle): Fix to the way idle
time is reported after the user comes back (but before they
resolve time).
* org.el (org-get-repeat): Change so that this function can be
called with either `org-scheduled-string' or
`org-deadline-string'.
* org-clock.el (org-clock-auto-clock-resolution): Renamed
`org-clock-disable-clock-resolution', since negatives don't sound
good in customization variables.
(org-clock-in): Don't use the auto-resolution logic if the user is
clocking into a different task while an active clock is running.
This then allows the default behavior of clocking out of the open
task and then into the new task.
* org.el (org-modules): Made this variable more consistent, since
it was referring to Org, OrgMode and Org-mode, whereas the docs
for the variable always refer to Org-mode.
2009-11-13 James TD Smith <ahktenzero@mohorovi.cc>
* org.el (org-repeat-re): The changed org-repeat-re no longer
matched simple +2d type repeaters. Fix it so it does.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-preprocess): Protect the vspace
macro in the VERSE environment.
2009-11-13 John Wiegley <jwiegley@gmail.com>
* org-habit.el (org-habit-get-priority): A new function that
determines the relative priority of a habit, based on how long
past its scheduled date it is, and how near the deadline is.
* org-agenda.el (org-agenda-get-scheduled): Set habit priority
using `org-habit-get-priority'.
* org-habit.el (org-habit-build-graph): Start displaying colors
from the first scheduled date, if that date is earlier than the
first completion date.
* org-habit.el: Changed all "color" variables to faces, and made
them appropriate for light and dark backgrounds.
* org-habit.el (org-habit-duration-to-days): Made this function
more general.
(org-habit-parse-todo): Parse the new ".+N/N" style repeater.
* org-agenda.el (org-agenda-get-deadlines): Removed all mention of
habits, since they don't use DEADLINE anymore.
* org.el (org-repeat-re, org-display-custom-time)
(org-timestamp-change): Extended to support the new ".+N/N"
syntax, used for habits.
* org-clock.el (org-clock-resolve-clock): Fixed an incorrect
variable reference.
* org-agenda.el (org-agenda-set-mode-name): Show Habit in the
modeline when habits are being displayed (if that module is being
loaded).
2009-11-13 James TD Smith <ahktenzero@mohorovi.cc>
* org-clock.el (org-x11-idle-seconds): Add a method to get the X11
idle time using the xscreensaver extension.
(org-user-idle-seconds): Use X11 idle time if available.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-next-line): New command.
(org-agenda-previous-line): New commands.
(org-agenda-show-and-scroll-up, org-agenda-show-scroll-down): New
commands.
(org-agenda-follow-mode): Do the follow immediately if the mode is
turned on here.
(previous-line, next-line): Replace keys with the corresponding
org functions.
(org-agenda-mode-map): Bind backspace and delete to the scrolling
command.
* org.el (org-icompleting-read): Turn off partial completion mode
for the duration of this completion round.
* org-latex.el (org-export-latex-fontify-headline): Protect TeX
macros in author lines and similar stuff.
* org.el (org-file-tags): Fix docstring.
(org-get-buffer-tags): Add the #+FILETAGS tags.
("ecb"): Maks ecb show context after jumping into an Org file.
2009-11-13 John Wiegley <johnw@newartisans.com>
* org-agenda.el (org-finalize-agenda): Draw habit consistency
graphs after everything else in the buffer has been setup.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-mobile.el (org-mobile-apply): Count success and failure.
* org.el (org-indent-line-function): Fix regexp replace problem.
2009-11-13 John Wiegley <johnw@newartisans.com>
* org-clock.el (org-clock-disable-clock-resolution): New
customization variable that disable automatic clock resolution on
clock in.
(org-clock-in): If `org-clock-disable-clock-resolution' is set, do
not automatically resolve anything. This is does not affect
idle-time resolution, however, if `org-clock-idle-time' is set.
2009-11-13 John Wiegley <johnw@newartisans.com>
* org-habit.el: New file, which implements code to build a "habit
consistency graph".
* org-agenda.el (org-agenda-get-deadlines)
(org-agenda-get-scheduled): Display consistency graphs when
outputting habits into the agenda. The graphs are always relative
to the current time.
(org-format-agenda-item): Added new parameter `habitp', which
indicates whether we are formatting a habit or not. Do not
display "extra" leading information if habitp is true.
* org.el (org-repeat-re): Improved regexp to include .+ and ++
leaders for repeat strings.
(org-get-repeat): Now takes a string parameter `tagline', so the
caller can obtain the SCHEDULED repeat, or the DEADLINE repeat.
2009-11-13 John Wiegley <johnw@newartisans.com>
* org-agenda.el (org-agenda-auto-exclude-function): New
customization variable for allowing the user to create an "auto
exclusion" filter for doing context-aware auto tag filtering.
(org-agenda-filter-by-tag): Changes to support the use of
`org-agenda-auto-exclude-function'. See the new manual addition,.
2009-11-13 John Wiegley <johnw@newartisans.com>
* org.el (org-files-list): Don't attempt to return a file name for
Org buffers which have no associated file.
* org-agenda.el (org-agenda-do-action): Fixed a typo.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-mobile.el (org-mobile-locate-entry): Interpret files
relative to org-directory.
(org-mobile-inbox-for-pull): Document the best location for this
file.
(org-mobile-check-setup): Verify `org-directory'.
(org-mobile-create-index-file): Sort the files to be listed in
index.org.
2009-11-13 James TD Smith <ahktenzero@mohorovi.cc>
* org.el (org-fast-tag-selection): Add a way to display a
description for a tag group. This is done by adding a string to
either the startgroup or endgroup cell.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-clock.el (org-clock-resolve, org-resolve-clocks)
(org-emacs-idle-seconds): Use `org-float-time' instead of
`time-to-seconds'
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-sorting-strategy): Fix customization
type.
* org.el (org-pre-cycle-hook): Document that `empty' can also be
the value of ARG when doing local cycling.
2009-11-13 John Wiegley <johnw@newartisans.com>
* org-clock.el (org-clock-resolve-clock): If keeping or
subtracting time results in a clock out at a time in the past, and
if the resolution occurred due to idleness or invoking `M-x
org-resolve-clocks', remember that past moment in time. On the
next clock in, the user will be prompted to see if they want to
back-date their new clock to then.
(org-clock-resolve): Do not jump the user to the location of a
dangling clock if the resolution is occuring due to an idle
timeout. In that case there is typically only one dangling clock,
the active one, and there is no value gained by shuffling their
windows around to show it to them. Being prompted to resolve an
idle clock should be as inobtrusive as possible.
(org-resolve-clocks-if-idle): New function that resolves only the
currently active clock if the user has exceeded the time returned
by `org-user-idle-seconds', based on the value of
`org-clock-idle-time'.
(org-clock-in): If, after resolving clocks,
(org-clock-out): Cancel the `org-clock-idle-timer' on clock out.
* org-clock.el (org-clock-resolve-clock): New function that
resolves a clock to a specific time, closing or resuming as need
be, and possibly even starting a new clock.
(org-clock-resolve): New function used by `org-resolve-clocks'
that sets up for the call to `org-clock-resolve-clock'. It
determines the time to resolve to based on a single-character
selection from the user to either keep time, subtract away time or
cancel the clock.
(org-resolve-clocks): New user command which resolves dangling
clocks -- that is, open but not active -- anywhere in the file
list returned by `org-files-list'.
(org-clock-in): Automatically resolve dangling clocks whenever a
user clocks in.
(org-clock-cancel): If the user cancels the solely clock in a
LOGBOOK, remove the empty drawer.
* org-clock.el (org-clock-idle-time): New user customizable option
for detecting whether the user has left a clock idle. Note: it is
only used in this commit to test whether it's worthwhile to check
OS X to get the Mac user's current idle time. If the Emacs idle
time is less than the value, the user hasn't been away long enough
to be worth checking (a more expensive test than just getting
Emacs idle time).
(org-user-idle-seconds, org-mac-idle-seconds)
(org-emacs-idle-seconds): This three functions, in conjunction
with the user customization variable `org-clock-idle-time', return
the number of seconds (as a floating point) that the user has been
away from their Emacs (or, if running on OS X, their computer).
* org-clock.el (org-find-open-clocks): New function that returns a
list of all open clocks in the given FILE. Note that each clock
it returns is a cons cell of the format (MARKER . START-TIME).
This "clock" value is used by several of the new clock module
utility functions.
(org-is-active-clock): New inline function which tests whether the
given clock value is the same as the currently active clock.
Returns non-nil if this is the case.
(org-with-clock-position): New macro that evaluates FORMS with
point in the buffer and at the position of the given clock.
Changes to the current clock are global.
(org-with-clock): New macro that evaluates FORMS with point in the
buffer and at the position of the given clock. However, changes
to the current clock are local and have no effect on the user's
active clock. This allows, for example, far any clock to be
cancelled without cancelling the active clock.
(org-clock-clock-in): New inline function that switches the active
clock to the given clock. If either the argument RESUME, or the
global `org-clock-in-resume', are non-nil, it will resume a clock
that was previously left open.
(org-clock-clock-out): New inline function that clocks out the
given clock value without affecting the currently active clock.
(org-clock-clock-cancel): New inline function that cancels the
given clock value without affecting the currently active clock.
* org-clock.el (org-clock-in): Before creating
`org-clock-mode-line-timer', check to make sure an older timer is
not currently running.
(org-clock-out): Accept new third parameter `at-time', which
permits a clock to be clocked out at a specific time. Note that
no attempt is made to verify that the clock out time is later than
the clock in time.
* org.el (org-files-list): New utility function for returning a
list of all open org-mode buffers, plus all files used to build
the agenda buffer. Note that not all the files will necessarily
be visited by a buffer at time of call.
(org-entry-beginning-position): Like the function
`line-beginning-position', this inline function returns the
beginning position of the current heading/entry.
(org-entry-end-position): Like the function `line-end-position',
this inline function returns the end position of the current
heading/entry.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-list): Mark the all-todo items line as
a header line.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-inlinetask-remove-END-maybe): Declare function.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-agenda.el (org-agenda-filter-make-matcher): Allow to filter
entries that have no tags.
(org-agenda-search-view): New customize group.
(org-agenda-search-view-search-words-only): New option.
(org-search-view): Implement substring search.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-outline-level): Add doc string.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-inlinetask.el (org-inlinetask-export): Re-introduce
variable.
(org-inlinetask-export-handler): Only export inline task if the
user option calls for it.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-exp.el (org-export-handle-export-tags): Remove inlinetask
END if present.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-latex.el (org-export-latex-tables): Don't format in
protected regions.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-src.el (org-edit-src-code)
(org-edit-src-find-region-and-lang, org-edit-src-exit): Handle
macro editing.
* org-agenda.el (org-prefix-category-max-length): New variable.
(org-format-agenda-item): Use `org-prefix-category-max-length'.
(org-compile-prefix-format): Set `org-prefix-category-max-length'.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-mobile.el (org-mobile-create-index-file): Improve the
listing of tags and todo keywords.
* org-latex.el (org-export-latex-format-image): New function.
(org-export-latex-links): Use `org-export-latex-format-image'.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org-inlinetask.el (org-inlinetask-get-current-indentation)
(org-inlinetask-remove-terminator): New functions.
(org-inlinetask-export-handler): Terminate the description list.
* org-exp.el (org-export-select-backend-specific-text): Remove the
region markers.
* org-inlinetask.el (org-inlinetask-export-handler): fix bug for
tasks without content.
* org-clock.el: Make sure the clock-in target position does not
move to a different node by widening the buffer.
* org-html.el (org-export-html-format-image): Wrap image into
figure div only when there is a caption.
* org-archive.el (org-archive-mark-done): Change default value to
nil.
2009-11-13 Carsten Dominik <carsten.dominik@gmail.com>
* org.el (org-context): Call `bobp', not `eobp'.
* org-clock.el (org-clock-cancel): Remove quotes from marker
variables.
* org.el (org-read-date-prefer-future): New allowed value `time'.
(org-read-date-analyze): Shift day to tomorrow depending on time
entered and value of `org-read-date-prefer-future'.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Fri, 13 Nov 2009 08:37:55 +0000 |
parents | 00c0adbb54a9 |
children | 1d1d5d9bd884 |
line wrap: on
line source
;;; mh-seq.el --- MH-E sequences support ;; Copyright (C) 1993, 1995, ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ;; Free Software Foundation, Inc. ;; Author: Bill Wohler <wohler@newt.com> ;; Maintainer: Bill Wohler <wohler@newt.com> ;; Keywords: mail ;; See: mh-e.el ;; This file is part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. ;;; Commentary: ;; Sequences are stored in the alist `mh-seq-list' in the form: ;; ((seq-name msgs ...) (seq-name msgs ...) ...) ;;; Change Log: ;;; Code: (require 'mh-e) (mh-require-cl) (require 'mh-scan) (require 'font-lock) ;;; Variables (defvar mh-last-seq-used nil "Name of seq to which a msg was last added.") (defvar mh-non-seq-mode-line-annotation nil "Saved value of `mh-mode-line-annotation' when narrowed to a seq.") (make-variable-buffer-local 'mh-non-seq-mode-line-annotation) (defvar mh-internal-seqs '(answered cur deleted forwarded printed)) ;;; Macros (defsubst mh-make-seq (name msgs) "Create sequence NAME with the given MSGS." (cons name msgs)) (defsubst mh-seq-name (sequence) "Extract sequence name from the given SEQUENCE." (car sequence)) ;;; MH-Folder Commands ;; Alphabetical. ;;;###mh-autoload (defun mh-catchup (range) "Delete RANGE from the \"unseen\" sequence. Check the documentation of `mh-interactive-range' to see how RANGE is read in interactive use." (interactive (list (mh-interactive-range "Catchup" (cons (point-min) (point-max))))) (mh-delete-msg-from-seq range mh-unseen-seq)) ;;;###mh-autoload (defun mh-delete-msg-from-seq (range sequence &optional internal-flag) "Delete RANGE from SEQUENCE. Check the documentation of `mh-interactive-range' to see how RANGE is read in interactive use. In a program, non-nil INTERNAL-FLAG means do not inform MH of the change." (interactive (list (mh-interactive-range "Delete") (mh-read-seq-default "Delete from" t) nil)) (let ((entry (mh-find-seq sequence)) (user-sequence-flag (not (mh-internal-seq sequence))) (folders-changed (list mh-current-folder)) (msg-list ())) (when entry (mh-iterate-on-range msg range (push msg msg-list) ;; Calling "mark" repeatedly takes too long. So we will pretend here ;; that we are just modifying an internal sequence... (when (memq msg (cdr entry)) (mh-remove-sequence-notation msg (not user-sequence-flag))) (mh-delete-a-msg-from-seq msg sequence t)) ;; ... and here we will "mark" all the messages at one go. (unless internal-flag (mh-undefine-sequence sequence msg-list)) (when (and mh-index-data (not internal-flag)) (setq folders-changed (append folders-changed (mh-index-delete-from-sequence sequence msg-list)))) (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p)) (apply #'mh-speed-flists t folders-changed))))) ;;;###mh-autoload (defun mh-delete-seq (sequence) "Delete SEQUENCE. You are prompted for the sequence to delete. Note that this deletes only the sequence, not the messages in the sequence. If you want to delete the messages, use \"\\[universal-argument] \\[mh-delete-msg]\"." (interactive (list (mh-read-seq-default "Delete" t))) (let ((msg-list (mh-seq-to-msgs sequence)) (internal-flag (mh-internal-seq sequence)) (folders-changed (list mh-current-folder))) (mh-iterate-on-range msg sequence (mh-remove-sequence-notation msg internal-flag)) (mh-undefine-sequence sequence '("all")) (mh-delete-seq-locally sequence) (when mh-index-data (setq folders-changed (append folders-changed (mh-index-delete-from-sequence sequence msg-list)))) (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p)) (apply #'mh-speed-flists t folders-changed)))) ;; Shush compiler. (defvar view-exit-action) ;;;###mh-autoload (defun mh-list-sequences () "List all sequences in folder. The list appears in a buffer named \"*MH-E Sequences*\"." (interactive) (let ((folder mh-current-folder) (temp-buffer mh-sequences-buffer) (seq-list mh-seq-list) (max-len 0)) (with-output-to-temp-buffer temp-buffer (with-current-buffer temp-buffer (erase-buffer) (message "Listing sequences ...") (insert "Sequences in folder " folder ":\n") (let ((seq-list seq-list)) (while seq-list (setq max-len (max (length (symbol-name (mh-seq-name (pop seq-list)))) max-len))) (setq max-len (+ 2 max-len))) (while seq-list (let ((name (mh-seq-name (car seq-list))) (sorted-seq-msgs (mh-coalesce-msg-list (sort (copy-sequence (mh-seq-msgs (car seq-list))) '<))) name-spec) (insert (setq name-spec (format (format "%%%ss:" max-len) name))) (while sorted-seq-msgs (let ((next-element (format " %s" (pop sorted-seq-msgs)))) (when (>= (+ (current-column) (length next-element)) (window-width)) (insert "\n") (insert (format (format "%%%ss" (length name-spec)) ""))) (insert next-element))) (insert "\n")) (setq seq-list (cdr seq-list))) (goto-char (point-min)) (mh-view-mode-enter) (setq view-exit-action 'kill-buffer) (message "Listing sequences...done"))))) ;;;###mh-autoload (defun mh-msg-is-in-seq (message) "Display the sequences in which the current message appears. Use a prefix argument to display the sequences in which another MESSAGE appears." (interactive "P") (if (not message) (setq message (mh-get-msg-num t))) (let* ((dest-folder (loop for seq in mh-refile-list when (member message (cdr seq)) return (car seq) finally return nil)) (deleted-flag (unless dest-folder (member message mh-delete-list)))) (message "Message %d%s is in sequences: %s" message (cond (dest-folder (format " (to be refiled to %s)" dest-folder)) (deleted-flag (format " (to be deleted)")) (t "")) (mapconcat 'concat (mh-list-to-string (mh-seq-containing-msg message t)) " ")))) ;; Shush compiler. (defvar tool-bar-mode) ; XEmacs (defvar tool-bar-map) ;;;###mh-autoload (defun mh-narrow-to-seq (sequence) "Restrict display to messages in SEQUENCE. You are prompted for the name of the sequence. What this command does is show only those messages that are in the selected sequence in the MH-Folder buffer. In addition, it limits further MH-E searches to just those messages. When you want to widen the view to all your messages again, use \\[mh-widen]." (interactive (list (mh-read-seq "Narrow to" t))) (with-mh-folder-updating (t) (cond ((mh-seq-to-msgs sequence) (mh-remove-all-notation) (let ((eob (point-max)) (msg-at-cursor (mh-get-msg-num nil))) (push mh-thread-scan-line-map mh-thread-scan-line-map-stack) (setq mh-thread-scan-line-map (make-hash-table :test #'eql)) (mh-copy-seq-to-eob sequence) (push (buffer-substring-no-properties (point-min) eob) mh-folder-view-stack) (delete-region (point-min) eob) (mh-notate-deleted-and-refiled) (mh-notate-cur) (when msg-at-cursor (mh-goto-msg msg-at-cursor t t)) (setq mh-non-seq-mode-line-annotation mh-mode-line-annotation) (setq mh-mode-line-annotation (symbol-name sequence)) (mh-make-folder-mode-line) (mh-recenter nil) (when (and (boundp 'tool-bar-mode) tool-bar-mode) (set (make-local-variable 'tool-bar-map) mh-folder-seq-tool-bar-map) (when (buffer-live-p (get-buffer mh-show-buffer)) (with-current-buffer mh-show-buffer (set (make-local-variable 'tool-bar-map) mh-show-seq-tool-bar-map)))) (push 'widen mh-view-ops))) (t (error "No messages in sequence %s" (symbol-name sequence)))))) ;;;###mh-autoload (defun mh-narrow-to-tick () "Limit to ticked messages. What this command does is show only those messages that are in the \"tick\" sequence (which you can customize via the `mh-tick-seq' option) in the MH-Folder buffer. In addition, it limits further MH-E searches to just those messages. When you want to widen the view to all your messages again, use \\[mh-widen]." (interactive) (cond ((not mh-tick-seq) (error "Enable ticking by customizing `mh-tick-seq'")) ((null (mh-seq-msgs (mh-find-seq mh-tick-seq))) (message "No messages in %s sequence" mh-tick-seq)) (t (mh-narrow-to-seq mh-tick-seq)))) ;;;###mh-autoload (defun mh-put-msg-in-seq (range sequence) "Add RANGE to SEQUENCE\\<mh-folder-mode-map>. Give this command a RANGE and you can add all the messages in a sequence to another sequence (for example, \"\\[universal-argument] \\[mh-put-msg-in-seq] SourceSequence RET DestSequence RET\"). Check the documentation of `mh-interactive-range' to see how RANGE is read in interactive use." (interactive (list (mh-interactive-range "Add messages from") (mh-read-seq-default "Add to" nil))) (unless (mh-valid-seq-p sequence) (error "Can't put message in invalid sequence %s" sequence)) (let* ((internal-seq-flag (mh-internal-seq sequence)) (original-msgs (mh-seq-msgs (mh-find-seq sequence))) (folders (list mh-current-folder)) (msg-list (mh-range-to-msg-list range))) (mh-add-msgs-to-seq msg-list sequence nil t) (mh-iterate-on-range m range (unless (memq m original-msgs) (mh-add-sequence-notation m internal-seq-flag))) (if (not internal-seq-flag) (setq mh-last-seq-used sequence)) (when mh-index-data (setq folders (append folders (mh-index-add-to-sequence sequence msg-list)))) (when (and (eq sequence mh-unseen-seq) (mh-speed-flists-active-p)) (apply #'mh-speed-flists t folders)))) ;;;###mh-autoload (defun mh-toggle-tick (range) "Toggle tick mark of RANGE. This command adds messages to the \"tick\" sequence (which you can customize via the option `mh-tick-seq'). This sequence can be viewed later with the \\[mh-index-ticked-messages] command. Check the documentation of `mh-interactive-range' to see how RANGE is read in interactive use." (interactive (list (mh-interactive-range "Tick"))) (unless mh-tick-seq (error "Enable ticking by customizing `mh-tick-seq'")) (let* ((tick-seq (mh-find-seq mh-tick-seq)) (tick-seq-msgs (mh-seq-msgs tick-seq)) (ticked ()) (unticked ())) (mh-iterate-on-range msg range (cond ((member msg tick-seq-msgs) (push msg unticked) (setcdr tick-seq (delq msg (cdr tick-seq))) (when (null (cdr tick-seq)) (setq mh-last-seq-used nil)) (mh-remove-sequence-notation msg (mh-colors-in-use-p))) (t (push msg ticked) (setq mh-last-seq-used mh-tick-seq) (let ((mh-seq-list (cons `(,mh-tick-seq ,msg) mh-seq-list))) (mh-add-sequence-notation msg (mh-colors-in-use-p)))))) (mh-add-msgs-to-seq ticked mh-tick-seq nil t) (mh-undefine-sequence mh-tick-seq unticked) (when mh-index-data (mh-index-add-to-sequence mh-tick-seq ticked) (mh-index-delete-from-sequence mh-tick-seq unticked)))) ;;;###mh-autoload (defun mh-widen (&optional all-flag) "Remove last restriction. Each limit or sequence restriction can be undone in turn with this command. Give this command a prefix argument ALL-FLAG to remove all limits and sequence restrictions." (interactive "P") (let ((msg (mh-get-msg-num nil))) (when mh-folder-view-stack (cond (all-flag (while (cdr mh-view-ops) (setq mh-view-ops (cdr mh-view-ops))) (when (eq (car mh-view-ops) 'widen) (setq mh-view-ops (cdr mh-view-ops)))) ((mh-valid-view-change-operation-p 'widen) nil) ((memq 'widen mh-view-ops) (while (not (eq (car mh-view-ops) 'widen)) (setq mh-view-ops (cdr mh-view-ops))) (setq mh-view-ops (cdr mh-view-ops))) (t (error "Widening is not applicable"))) ;; If ALL-FLAG is non-nil then rewind stacks (when all-flag (while (cdr mh-thread-scan-line-map-stack) (setq mh-thread-scan-line-map-stack (cdr mh-thread-scan-line-map-stack))) (while (cdr mh-folder-view-stack) (setq mh-folder-view-stack (cdr mh-folder-view-stack)))) (setq mh-thread-scan-line-map (pop mh-thread-scan-line-map-stack)) (with-mh-folder-updating (t) (delete-region (point-min) (point-max)) (insert (pop mh-folder-view-stack)) (mh-remove-all-notation) (setq mh-mode-line-annotation mh-non-seq-mode-line-annotation) (mh-make-folder-mode-line)) (if msg (mh-goto-msg msg t t)) (mh-notate-deleted-and-refiled) (mh-notate-user-sequences) (mh-notate-cur) (mh-recenter nil))) (when (and (null mh-folder-view-stack) (boundp 'tool-bar-mode) tool-bar-mode) (set (make-local-variable 'tool-bar-map) mh-folder-tool-bar-map) (when (buffer-live-p (get-buffer mh-show-buffer)) (with-current-buffer mh-show-buffer (set (make-local-variable 'tool-bar-map) mh-show-tool-bar-map))))) ;;; Support Routines (defvar mh-sequence-history ()) ;;;###mh-autoload (defun mh-read-seq-default (prompt not-empty) "Read and return sequence name with default narrowed or previous sequence. PROMPT is the prompt to use when reading. If NOT-EMPTY is non-nil then a non-empty sequence is read." (mh-read-seq prompt not-empty (or mh-last-seq-used (car (mh-seq-containing-msg (mh-get-msg-num nil) nil))))) (defun mh-read-seq (prompt not-empty &optional default) "Read and return a sequence name. Prompt with PROMPT, raise an error if the sequence is empty and the NOT-EMPTY flag is non-nil, and supply an optional DEFAULT sequence. A reply of '%' defaults to the first sequence containing the current message." (let* ((input (completing-read (format "%s sequence%s: " prompt (if default (format " (default %s)" default) "")) (mh-seq-names mh-seq-list) nil nil nil 'mh-sequence-history)) (seq (cond ((equal input "%") (car (mh-seq-containing-msg (mh-get-msg-num t) nil))) ((equal input "") default) (t (intern input)))) (msgs (mh-seq-to-msgs seq))) (if (and (null msgs) not-empty) (error "No messages in sequence %s" seq)) seq)) (defun mh-internal-seq (name) "Return non-nil if NAME is the name of an internal MH-E sequence." (or (memq name mh-internal-seqs) (eq name mh-unseen-seq) (and (mh-colors-in-use-p) mh-tick-seq (eq name mh-tick-seq)) (eq name mh-previous-seq) (mh-folder-name-p name))) ;;;###mh-autoload (defun mh-valid-seq-p (name) "Return non-nil if NAME is a valid MH sequence name." (and (symbolp name) (string-match "^[a-zA-Z][a-zA-Z0-9]*$" (symbol-name name)))) ;;;###mh-autoload (defun mh-find-seq (name) "Return sequence NAME." (assoc name mh-seq-list)) ;;;###mh-autoload (defun mh-seq-to-msgs (seq) "Return a list of the messages in SEQ." (mh-seq-msgs (mh-find-seq seq))) (defun mh-seq-containing-msg (msg &optional include-internal-flag) "Return a list of the sequences containing MSG. If INCLUDE-INTERNAL-FLAG non-nil, include MH-E internal sequences in list." (let ((l mh-seq-list) (seqs ())) (while l (and (memq msg (mh-seq-msgs (car l))) (or include-internal-flag (not (mh-internal-seq (mh-seq-name (car l))))) (setq seqs (cons (mh-seq-name (car l)) seqs))) (setq l (cdr l))) seqs)) ;;;###mh-autoload (defun mh-define-sequence (seq msgs) "Define the SEQ to contain the list of MSGS. Do not mark pseudo-sequences or empty sequences. Signals an error if SEQ is an invalid name." (if (and msgs (mh-valid-seq-p seq) (not (mh-folder-name-p seq))) (save-excursion (mh-exec-cmd-error nil "mark" mh-current-folder "-add" "-zero" "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs))))) ;;;###mh-autoload (defun mh-undefine-sequence (seq msgs) "Remove from the SEQ the list of MSGS." (when (and (mh-valid-seq-p seq) msgs) (apply #'mh-exec-cmd "mark" mh-current-folder "-delete" "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs)))) ;;;###mh-autoload (defun mh-add-msgs-to-seq (msgs seq &optional internal-flag dont-annotate-flag) "Add MSGS to SEQ. Remove duplicates and keep sequence sorted. If optional INTERNAL-FLAG is non-nil, do not mark the message in the scan listing or inform MH of the addition. If DONT-ANNOTATE-FLAG is non-nil then the annotations in the folder buffer are not updated." (let ((entry (mh-find-seq seq)) (internal-seq-flag (mh-internal-seq seq))) (if (and msgs (atom msgs)) (setq msgs (list msgs))) (if (null entry) (setq mh-seq-list (cons (mh-make-seq seq (mh-canonicalize-sequence msgs)) mh-seq-list)) (if msgs (setcdr entry (mh-canonicalize-sequence (append msgs (mh-seq-msgs entry)))))) (unless internal-flag (mh-add-to-sequence seq msgs) (when (not dont-annotate-flag) (mh-iterate-on-range msg msgs (unless (memq msg (cdr entry)) (mh-add-sequence-notation msg internal-seq-flag))))))) (defun mh-add-to-sequence (seq msgs) "The sequence SEQ is augmented with the messages in MSGS." ;; Add to a SEQUENCE each message the list of MSGS. (if (and (mh-valid-seq-p seq) (not (mh-folder-name-p seq))) (if msgs (apply 'mh-exec-cmd "mark" mh-current-folder "-add" "-sequence" (symbol-name seq) (mh-coalesce-msg-list msgs))))) (defun mh-canonicalize-sequence (msgs) "Sort MSGS in decreasing order and remove duplicates." (let* ((sorted-msgs (sort (copy-sequence msgs) '>)) (head sorted-msgs)) (while (cdr head) (if (= (car head) (cadr head)) (setcdr head (cddr head)) (setq head (cdr head)))) sorted-msgs)) (defun mh-delete-a-msg-from-seq (msg sequence internal-flag) "Delete MSG from SEQUENCE. If INTERNAL-FLAG is non-nil, then do not inform MH of the change." (let ((entry (mh-find-seq sequence))) (when (and entry (memq msg (mh-seq-msgs entry))) (if (not internal-flag) (mh-undefine-sequence sequence (list msg))) (setcdr entry (delq msg (mh-seq-msgs entry)))))) (defun mh-delete-seq-locally (seq) "Remove MH-E's record of SEQ." (let ((entry (mh-find-seq seq))) (setq mh-seq-list (delq entry mh-seq-list)))) (defun mh-copy-seq-to-eob (seq) "Copy SEQ to the end of the buffer." ;; It is quite involved to write something which will work at any place in ;; the buffer, so we will write something which works only at the end of ;; the buffer. If we ever need to insert sequences in the middle of the ;; buffer, this will need to be fixed. (save-excursion (let* ((msgs (mh-seq-to-msgs seq)) (coalesced-msgs (mh-coalesce-msg-list msgs))) (goto-char (point-max)) (save-restriction (narrow-to-region (point) (point)) (mh-regenerate-headers coalesced-msgs t) (cond ((memq 'unthread mh-view-ops) ;; Populate restricted scan-line map (mh-remove-all-notation) (mh-iterate-on-range msg (cons (point-min) (point-max)) (setf (gethash msg mh-thread-scan-line-map) (mh-thread-parse-scan-line))) ;; Remove scan lines and read results from pre-computed tree (delete-region (point-min) (point-max)) (mh-thread-print-scan-lines (mh-thread-generate mh-current-folder ())) (mh-notate-user-sequences)) (mh-index-data (mh-index-insert-folder-headers))))))) ;;;###mh-autoload (defun mh-valid-view-change-operation-p (op) "Check if the view change operation can be performed. OP is one of 'widen and 'unthread." (cond ((eq (car mh-view-ops) op) (pop mh-view-ops)) (t nil))) ;;; Ranges (defvar mh-range-seq-names) (defvar mh-range-history ()) (defvar mh-range-completion-map (copy-keymap minibuffer-local-completion-map)) (define-key mh-range-completion-map " " 'self-insert-command) ;;;###mh-autoload (defun mh-interactive-range (range-prompt &optional default) "Return interactive specification for message, sequence, range or region. By convention, the name of this argument is RANGE. If variable `transient-mark-mode' is non-nil and the mark is active, then this function returns a cons-cell of the region. If optional prefix argument is provided, then prompt for message range with RANGE-PROMPT. A list of messages in that range is returned. If a MH range is given, say something like last:20, then a list containing the messages in that range is returned. If DEFAULT non-nil then it is returned. Otherwise, the message number at point is returned. This function is usually used with `mh-iterate-on-range' in order to provide a uniform interface to MH-E functions." (cond ((mh-mark-active-p t) (cons (region-beginning) (region-end))) (current-prefix-arg (mh-read-range range-prompt nil nil t t)) (default default) (t (mh-get-msg-num t)))) ;;;###mh-autoload (defun mh-read-range (prompt &optional folder default expand-flag ask-flag number-as-range-flag) "Read a message range with PROMPT. If FOLDER is non-nil then a range is read from that folder, otherwise use `mh-current-folder'. If DEFAULT is a string then use that as default range to return. If DEFAULT is nil then ask user with default answer a range based on the sequences that seem relevant. Finally if DEFAULT is t, try to avoid prompting the user. Unseen messages, if present, are returned. If the folder has fewer than `mh-large-folder' messages then \"all\" messages are returned. Finally as a last resort prompt the user. If EXPAND-FLAG is non-nil then a list of message numbers corresponding to the input is returned. If this list is empty then an error is raised. If EXPAND-FLAG is nil just return the input string. In this case we don't check if the range is empty. If ASK-FLAG is non-nil, then the user is always queried for a range of messages. If ASK-FLAG is nil, then the function checks if the unseen sequence is non-empty. If that is the case, `mh-unseen-seq', or the list of messages in it depending on the value of EXPAND, is returned. Otherwise if the folder has fewer than `mh-large-folder' messages then the list of messages corresponding to \"all\" is returned. If neither of the above holds then as a last resort the user is queried for a range of messages. If NUMBER-AS-RANGE-FLAG is non-nil, then if a number, N is read as input, it is interpreted as the range \"last:N\". This function replaces the existing function `mh-read-msg-range'. Calls to: (mh-read-msg-range folder flag) should be replaced with: (mh-read-range \"Suitable prompt\" folder t nil flag mh-interpret-number-as-range-flag)" (setq default (or default mh-last-seq-used (car (mh-seq-containing-msg (mh-get-msg-num nil) t))) prompt (format "%s range" prompt)) (let* ((folder (or folder mh-current-folder)) (guess (eq default t)) (counts (and guess (mh-folder-size folder))) (unseen (and counts (> (cadr counts) 0))) (large (and counts mh-large-folder (> (car counts) mh-large-folder))) (default (cond ((and guess large) (format "last:%s" mh-large-folder)) ((and guess (not large)) "all") ((stringp default) default) ((symbolp default) (symbol-name default)))) (prompt (cond ((and guess large default) (format "%s (folder has %s messages, default %s)" prompt (car counts) default)) ((and guess large) (format "%s (folder has %s messages)" prompt (car counts))) (default (format "%s (default %s)" prompt default)))) (minibuffer-local-completion-map mh-range-completion-map) (seq-list (if (eq folder mh-current-folder) mh-seq-list (mh-read-folder-sequences folder nil))) (mh-range-seq-names (append '(("first") ("last") ("all") ("prev") ("next")) (mh-seq-names seq-list))) (input (cond ((and (not ask-flag) unseen) (symbol-name mh-unseen-seq)) ((and (not ask-flag) (not large)) "all") (t (completing-read (format "%s: " prompt) 'mh-range-completion-function nil nil nil 'mh-range-history default)))) msg-list) (when (and number-as-range-flag (string-match "^[ \t]*\\([0-9]+\\)[ \t]*$" input)) (setq input (concat "last:" (match-string 1 input)))) (cond ((not expand-flag) input) ((assoc (intern input) seq-list) (cdr (assoc (intern input) seq-list))) ((setq msg-list (mh-translate-range folder input)) msg-list) (t (error "No messages in range %s" input))))) ;;;###mh-autoload (defun mh-range-to-msg-list (range) "Return a list of messages for RANGE. Check the documentation of `mh-interactive-range' to see how RANGE is read in interactive use." (let (msg-list) (mh-iterate-on-range msg range (push msg msg-list)) (nreverse msg-list))) ;;;###mh-autoload (defun mh-translate-range (folder expr) "In FOLDER, translate the string EXPR to a list of messages numbers." (save-excursion (let ((strings (delete "" (split-string expr "[ \t\n]"))) (result ())) (ignore-errors (apply #'mh-exec-cmd-quiet nil "mhpath" folder strings) (set-buffer mh-temp-buffer) (goto-char (point-min)) (while (re-search-forward "/\\([0-9]*\\)$" nil t) (push (string-to-number (match-string 1)) result)) (nreverse result))))) (defun mh-range-completion-function (string predicate flag) "Programmable completion of message ranges. STRING is the user input that is to be completed. PREDICATE if non-nil is a function used to filter the possible choices and FLAG determines whether the completion is over." (let* ((candidates mh-range-seq-names) (last-char (and (not (equal string "")) (aref string (1- (length string))))) (last-word (cond ((null last-char) "") ((memq last-char '(? ?- ?:)) "") (t (car (last (split-string string "[ -:]+")))))) (prefix (substring string 0 (- (length string) (length last-word))))) (cond ((eq flag nil) (let ((res (try-completion last-word candidates predicate))) (cond ((null res) nil) ((eq res t) t) (t (concat prefix res))))) ((eq flag t) (all-completions last-word candidates predicate)) ((eq flag 'lambda) (loop for x in candidates when (equal x last-word) return t finally return nil))))) (defun mh-seq-names (seq-list) "Return an alist containing the names of the SEQ-LIST." (mapcar (lambda (entry) (list (symbol-name (mh-seq-name entry)))) seq-list)) (defun mh-folder-size (folder) "Find size of FOLDER." (if mh-flists-present-flag (mh-folder-size-flist folder) (mh-folder-size-folder folder))) (defun mh-folder-size-flist (folder) "Find size of FOLDER using \"flist\"." (with-temp-buffer (call-process (expand-file-name "flist" mh-progs) nil t nil "-showzero" "-norecurse" folder "-sequence" (symbol-name mh-unseen-seq)) (goto-char (point-min)) (multiple-value-bind (folder unseen total) (values-list (mh-parse-flist-output-line (buffer-substring (point) (mh-line-end-position)))) (list total unseen folder)))) (defun mh-folder-size-folder (folder) "Find size of FOLDER using \"folder\"." (with-temp-buffer (let ((u (length (cdr (assoc mh-unseen-seq (mh-read-folder-sequences folder nil)))))) (call-process (expand-file-name "folder" mh-progs) nil t nil "-norecurse" folder) (goto-char (point-min)) (if (re-search-forward " has \\([0-9]+\\) " nil t) (list (string-to-number (match-string 1)) u folder) (list 0 u folder))))) ;;;###mh-autoload (defun mh-parse-flist-output-line (line &optional current-folder) "Parse LINE to generate folder name, unseen messages and total messages. If CURRENT-FOLDER is non-nil then it contains the current folder name and it is used to avoid problems in corner cases involving folders whose names end with a '+' character." (with-temp-buffer (insert line) (goto-char (point-max)) (let (folder unseen total p) (when (search-backward " out of " (point-min) t) (setq total (string-to-number (buffer-substring-no-properties (match-end 0) (mh-line-end-position)))) (when (search-backward " in sequence " (point-min) t) (setq p (point)) (when (search-backward " has " (point-min) t) (setq unseen (string-to-number (buffer-substring-no-properties (match-end 0) p))) (while (eq (char-after) ? ) (backward-char)) (setq folder (buffer-substring-no-properties (point-min) (1+ (point)))) (when (and (equal (aref folder (1- (length folder))) ?+) (equal current-folder folder)) (setq folder (substring folder 0 (1- (length folder))))) (list (format "+%s" folder) unseen total))))))) ;;;###mh-autoload (defun mh-read-folder-sequences (folder save-refiles) "Read and return the predefined sequences for a FOLDER. If SAVE-REFILES is non-nil, then keep the sequences that note messages to be refiled." (let ((seqs ())) (cond (save-refiles (mh-mapc (function (lambda (seq) ; Save the refiling sequences (if (mh-folder-name-p (mh-seq-name seq)) (setq seqs (cons seq seqs))))) mh-seq-list))) (save-excursion (if (eq 0 (mh-exec-cmd-quiet nil "mark" folder "-list")) (progn ;; look for name in line of form "cur: 4" or "myseq (private): 23" (while (re-search-forward "^[^: ]+" nil t) (setq seqs (cons (mh-make-seq (intern (buffer-substring (match-beginning 0) (match-end 0))) (mh-read-msg-list)) seqs))) (delete-region (point-min) (point))))) ; avoid race with ; mh-process-daemon seqs)) (defun mh-read-msg-list () "Return a list of message numbers from point to the end of the line. Expands ranges into set of individual numbers." (let ((msgs ()) (end-of-line (save-excursion (end-of-line) (point))) num) (while (re-search-forward "[0-9]+" end-of-line t) (setq num (string-to-number (buffer-substring (match-beginning 0) (match-end 0)))) (cond ((looking-at "-") ; Message range (forward-char 1) (re-search-forward "[0-9]+" end-of-line t) (let ((num2 (string-to-number (buffer-substring (match-beginning 0) (match-end 0))))) (if (< num2 num) (error "Bad message range: %d-%d" num num2)) (while (<= num num2) (setq msgs (cons num msgs)) (setq num (1+ num))))) ((not (zerop num)) ;"pick" outputs "0" to mean no match (setq msgs (cons num msgs))))) msgs)) ;;; Notation ;;;###mh-autoload (defun mh-notate (msg notation offset) "Mark MSG with the character NOTATION at position OFFSET. Null MSG means the message at cursor. If NOTATION is nil then no change in the buffer occurs." (save-excursion (if (or (null msg) (mh-goto-msg msg t t)) (with-mh-folder-updating (t) (beginning-of-line) (forward-char offset) (let* ((change-stack-flag (and (equal offset (+ mh-cmd-note mh-scan-field-destination-offset)) (not (eq notation mh-note-seq)))) (msg (and change-stack-flag (or msg (mh-get-msg-num nil)))) (stack (and msg (gethash msg mh-sequence-notation-history))) (notation (or notation (char-after)))) (if stack ;; The presence of the stack tells us that we don't need to ;; notate the message, since the notation would be replaced ;; by a sequence notation. So we will just put the notation ;; at the bottom of the stack. If the sequence is deleted, ;; the correct notation will be shown. (setf (gethash msg mh-sequence-notation-history) (reverse (cons notation (cdr (reverse stack))))) ;; Since we don't have any sequence notations in the way, just ;; notate the scan line. (delete-char 1) (insert notation)) (when change-stack-flag (mh-thread-update-scan-line-map msg notation offset))))))) ;;;###mh-autoload (defun mh-notate-cur () "Mark the MH sequence cur. In addition to notating the current message with `mh-note-cur' the function uses `overlay-arrow-position' to put a marker in the fringe." (let ((cur (car (mh-seq-to-msgs 'cur)))) (when (and cur (mh-goto-msg cur t t)) (beginning-of-line) (when (looking-at mh-scan-good-msg-regexp) (mh-notate nil mh-note-cur mh-cmd-note)) (setq mh-arrow-marker (set-marker mh-arrow-marker (point))) (setq overlay-arrow-position mh-arrow-marker)))) ;;;###mh-autoload (defun mh-remove-cur-notation () "Remove old cur notation." (let ((cur-msg (car (mh-seq-to-msgs 'cur)))) (save-excursion (when (and cur-msg (mh-goto-msg cur-msg t t) (looking-at mh-scan-cur-msg-number-regexp)) (mh-notate nil ? mh-cmd-note) (setq overlay-arrow-position nil))))) ;; FIXME? We may want to clear all notations and add one for current-message ;; and process user sequences. ;;;###mh-autoload (defun mh-notate-deleted-and-refiled () "Notate messages marked for deletion or refiling. Messages to be deleted are given by `mh-delete-list' while messages to be refiled are present in `mh-refile-list'." (let ((refiled-hash (make-hash-table)) (deleted-hash (make-hash-table))) (dolist (msg mh-delete-list) (setf (gethash msg deleted-hash) t)) (dolist (dest-msg-list mh-refile-list) (dolist (msg (cdr dest-msg-list)) (setf (gethash msg refiled-hash) t))) (mh-iterate-on-messages-in-region msg (point-min) (point-max) (cond ((gethash msg refiled-hash) (mh-notate nil mh-note-refiled mh-cmd-note)) ((gethash msg deleted-hash) (mh-notate nil mh-note-deleted mh-cmd-note)))))) ;;;###mh-autoload (defun mh-notate-user-sequences (&optional range) "Mark user-defined sequences in RANGE. Check the documentation of `mh-interactive-range' to see how RANGE is read in interactive use; if nil all messages are notated." (unless range (setq range (cons (point-min) (point-max)))) (let ((seqs mh-seq-list) (msg-hash (make-hash-table))) (dolist (seq seqs) (dolist (msg (mh-seq-msgs seq)) (push (car seq) (gethash msg msg-hash)))) (mh-iterate-on-range msg range (loop for seq in (gethash msg msg-hash) do (mh-add-sequence-notation msg (mh-internal-seq seq)))))) (defun mh-add-sequence-notation (msg internal-seq-flag) "Add sequence notation to the MSG on the current line. If INTERNAL-SEQ-FLAG is non-nil, then refontify the scan line if font-lock is turned on." (with-mh-folder-updating (t) (save-excursion (beginning-of-line) (if internal-seq-flag (progn ;; Change the buffer so that if transient-mark-mode is active ;; and there is an active region it will get deactivated as in ;; the case of user sequences. (mh-notate nil nil mh-cmd-note) (when font-lock-mode (font-lock-fontify-region (point) (mh-line-end-position)))) (forward-char (+ mh-cmd-note mh-scan-field-destination-offset)) (let ((stack (gethash msg mh-sequence-notation-history))) (setf (gethash msg mh-sequence-notation-history) (cons (char-after) stack))) (mh-notate nil mh-note-seq (+ mh-cmd-note mh-scan-field-destination-offset)))))) (defun mh-remove-sequence-notation (msg internal-seq-flag &optional all) "Remove sequence notation from the MSG on the current line. If INTERNAL-SEQ-FLAG is non-nil, then `font-lock' was used to highlight the sequence. In that case, no notation needs to be removed. Otherwise the effect of inserting `mh-note-seq' needs to be reversed. If ALL is non-nil, then all sequence marks on the scan line are removed." (with-mh-folder-updating (t) ;; This takes care of internal sequences... (mh-notate nil nil mh-cmd-note) (unless internal-seq-flag ;; ... and this takes care of user sequences. (let ((stack (gethash msg mh-sequence-notation-history))) (while (and all (cdr stack)) (setq stack (cdr stack))) (when stack (save-excursion (beginning-of-line) (forward-char (+ mh-cmd-note mh-scan-field-destination-offset)) (delete-char 1) (insert (car stack)))) (setf (gethash msg mh-sequence-notation-history) (cdr stack)))))) ;;;###mh-autoload (defun mh-remove-all-notation () "Remove all notations on all scan lines that MH-E introduces." (save-excursion (setq overlay-arrow-position nil) (goto-char (point-min)) (mh-iterate-on-range msg (cons (point-min) (point-max)) (mh-notate nil ? mh-cmd-note) (mh-remove-sequence-notation msg nil t)) (clrhash mh-sequence-notation-history))) ;; XXX Unused, delete, or create bind key? (defun mh-rename-seq (sequence new-name) "Rename SEQUENCE to have NEW-NAME." (interactive (list (mh-read-seq "Old" t) (intern (read-string "New sequence name: ")))) (let ((old-seq (mh-find-seq sequence))) (or old-seq (error "Sequence %s does not exist" sequence)) ;; Create new sequence first, since it might raise an error. (mh-define-sequence new-name (mh-seq-msgs old-seq)) (mh-undefine-sequence sequence (mh-seq-msgs old-seq)) (rplaca old-seq new-name))) (provide 'mh-seq) ;; Local Variables: ;; indent-tabs-mode: nil ;; sentence-end-double-space: nil ;; End: ;; arch-tag: 8e952711-01a2-485b-bf21-c9e3ad4de942 ;;; mh-seq.el ends here