Commit graph

117 commits

Author SHA1 Message Date
stardiviner
85dd965906 Remove testing code 2021-11-18 15:08:05 +08:00
stardiviner
f3fa9fc0b8 use less magic symbol extract code
> #+begin_src emacs-lisp
> (defun org-contacts-org-complete-function ()
>   "Function used in `completion-at-point-functions' in `org-mode' to complete @name."
>   (when-let* ((bounds (bounds-of-thing-at-point 'symbol))
>               (begin (1- (car bounds)))
>               (end (cdr bounds))
>               (symbol (buffer-substring-no-properties begin end))
>               (org-contacts-prefix-p (string-prefix-p "@" symbol))
>               ;; (prefix (substring-no-properties symbol 1 nil))
>               )
>     (when org-contacts-prefix-p
>       (list begin
>             end
>             (completion-table-dynamic
>              (lambda (_)
>                (mapcar
>                 (lambda (contact) (plist-get contact :name))
>                 (org-contacts--all-contacts))))))))
> #+end_src

This gives a `begin..end` region which presumably includes `@`.
Does (plist-get contact :name) return names that start with `@`?
If not, the completion will never match.

> And test with execute following ~add-hook~ in org-mode buffer or
>  emacs-lisp-mode buffer:

In emacs-lisp-mode, `@` has symbol syntax, so
(bounds-of-thing-at-point 'symbol)
will include `@` in the returned region, whereas in Org mode
`@` seems to have punctuation syntax so the `@` will not be included in
the returned region.

Maybe instead of `bounds-of-thing-at-point` you want to use something
less "magic", like (skip-chars-backward "[:alnum:]@").
2021-11-18 15:06:23 +08:00
stardiviner
1b028de47c Fix contacts complete not working problem
> I found ~org-contacts-org-complete-function~ returned a special value:
>
> #+begin_example
> #f(compiled-function (string pred action) #<bytecode -0x9e1a398d61d3acb>)
> #+end_example

I can't see any way M-: (org-contacts-org-complete-function) RET
can return the above value.  So I suspect a "pilot error".
This looks like the 3rd value in the returned list (i.e. the value
returned by `completion-table-dynamic`).

> #+begin_src emacs-lisp
> (defun org-contacts-org-complete-function ()
>   "Function used in `completion-at-point-functions' in `org-mode' to complete @name."
>   (when-let* ((bounds (bounds-of-thing-at-point 'symbol))
>               (begin (1- (car bounds)))
>               (end (cdr bounds))
>               (symbol (buffer-substring-no-properties begin end))
>               (org-contacts-prefix-p (string-prefix-p "@" symbol))
>               ;; (prefix (substring-no-properties symbol 1 nil))
>               )
>     (when org-contacts-prefix-p
>       (list begin
>             end
>             (completion-table-dynamic
>              (lambda (_)
>                (mapcar
>                 (lambda (contact) (plist-get contact :name))
>                 (org-contacts--all-contacts))))))))
> #+end_src

This gives a `begin..end` region which presumably includes `@`.
Does (plist-get contact :name) return names that start with `@`?
If not, the completion will never match.

> And test with execute following ~add-hook~ in org-mode buffer or
>  emacs-lisp-mode buffer:

In emacs-lisp-mode, `@` has symbol syntax, so
(bounds-of-thing-at-point 'symbol)
will include `@` in the returned region, whereas in Org mode
`@` seems to have punctuation syntax so the `@` will not be included in
the returned region.

Maybe instead of `bounds-of-thing-at-point` you want to use something
less "magic", like (skip-chars-backward "[:alnum:]@").

> #+begin_src emacs-lisp
> (add-hook 'completion-at-point-functions 'org-contacts-org-complete-function nil 'local)
> #+end_src
2021-11-18 15:05:11 +08:00
stardiviner
c1d2b6dfbc prototype of org-contacts contact complete 2021-11-18 14:26:22 +08:00
stardiviner
f64d6edcd0 Update source code metadata keywords and usage description 2021-11-13 16:32:19 +08:00
stardiviner
038a608e79 Fix AVATAR property value not exist problem 2021-11-13 16:32:19 +08:00
stardiviner
c8408cf44e replace gnus-rescale-image with create-image property :height 2021-11-13 16:32:19 +08:00
stardiviner
00560d5f4f Try to support different type of AVATAR property.
- Support [[file:dir/filename.png]] link
- Support empty value
- Support default value
2021-11-13 16:32:19 +08:00
Morgan Smith
0a91557ef9 Tidy up whitespace 2021-11-13 16:30:06 +08:00
Morgan Smith
80ab4708b7 Change how completion is done 2021-11-13 16:29:16 +08:00
Morgan Smith
c98281fcfe Remove compatibility code 2021-11-13 16:27:52 +08:00
Morgan Smith
46726d2637 Don't use deprecated functions 2021-11-13 16:27:38 +08:00
Bastien Guerry
4540f987ec Clean up some more headers 2021-05-05 09:02:22 +02:00
Bastien Guerry
74019274c0 Update copyright years 2021-05-03 23:04:40 +02:00
Stefan Kangas
986a5b3280 Prefer HTTPS to HTTP in most links 2021-03-21 15:21:22 -04:00
Stefan Kangas
2f8b3f024c Prefer HTTPS to HTTP for links to gnu.org 2021-03-21 14:29:13 -04:00
stardiviner
0af8ca84b4 org-contacts.el: Display contacts buffer result.
* contrib/lisp/org-contacts.el (org-contacts-link-open): Display the
searched contacts file buffer.
2021-01-25 10:04:40 +08:00
Ihor Radchenko
1991ef0ecd Fix typo in 304fd01fe 2021-01-10 17:13:38 -05:00
stardiviner
0e33f05c4e org-contacts.el: Fix store link function does not return link.
* contrib/lisp/org-contacts.el (org-contacts-link-store): Fix
org-store-link return incorrect link without link type prefix.
2021-01-05 19:30:36 +08:00
David Florness
3d9181c0c4 org-contacts.el: Use `bound-and-true-p' to check (unbound) var
* org-contacts.el (org-contacts-link-store): Use `bound-and-true-p' to
check the truthiness of org-id-link-to-org-use-id, which may or may
not be bound depending on whether org-id has been loaded.  This
simplifies the code.
2021-01-05 19:28:11 +08:00
David Florness
eedaff3498 org-contacts.el: Only use org-id-store-link if org-id is loaded
Fixes bug introduced in c8ceb5290 that made org-contacts-anniversaries
error if org-id was not loaded.
2021-01-05 01:33:20 +08:00
stardiviner
af3a5cb6fa org-contacts.el: replace obsolete alias loop' with cl-loop'
* contrib/lisp/org-contacts.el (org-contacts-get-icon): replace obsolete
alias `loop' with `cl-loop'.
2021-01-03 20:17:37 +08:00
stardiviner
304fd01fe3 org-contacts.el: Add usage comments
* contrib/lisp/org-contacts.el: Add usage comments.
2021-01-03 20:16:41 +08:00
stardiviner
0107e8ecdb org-contacts.el: Inherit face from org-link
* contrib/lisp/org-contacts.el (org-contacts-link-face): Don't use a
color for org-contacts line, inherit from face org-link directly.
2020-12-20 20:43:23 +08:00
stardiviner
c8ceb5290e org-contacts.el: Add support for org-id generated link.
* contrib/lisp/org-contacts.el (org-contacts-link-store): Use org-id
store link if org-id-link-to-org-use-id is t.
2020-12-17 14:38:15 +08:00
stardiviner
ca3b10d5a8 org-contacts.el: Fix org-store-link error caused by org-contacts
* contrib/lisp/org-contacts.el (org-contacts-link-store): Fix Org store
link by adding missing condition for org-contacts.
2020-12-17 14:38:11 +08:00
Bastien
2c0bb90259 contrib/lisp/org-contacts.el: Add stardiviner as the maintainer 2020-12-15 15:26:35 +01:00
stardiviner
478dfcc9b7 org-contacts.el: Add new link type "contact:"
* contrib/lisp/org-contacts.el (org-contacts-link-store): Store a link
of org-contacts in Org file.

* contrib/lisp/org-contacts.el (org-contacts-link-open): Open contact:
link in Org file.

* contrib/lisp/org-contacts.el (org-contacts-link-complete): Insert a
contact: link with completion of contacts.

* contrib/lisp/org-contacts.el (org-contacts-link-face): Set different
face for contact: link.
2020-11-11 09:35:01 +01:00
Nicolas Goaziou
4e3f139857 Fix function declarations 2019-03-10 18:00:36 +01:00
Nicolas Goaziou
e64df72db4 Rationalize `org-link-(un)escape'
* contrib/lisp/org-contacts.el (org-contacts-vcard-format):
* contrib/lisp/org-link-edit.el (org-link-edit--link-data):
* contrib/lisp/org-notmuch.el (org-notmuch-search-store-link):
(org-notmuch-search-follow-link):
(org-notmuch-tree-follow-link):
* lisp/org-docview.el (org-docview-export):
* lisp/org-element.el (org-element-link-parser):
* lisp/org-lint.el (org-lint-link-to-local-file):
* lisp/org-protocol.el (org-protocol-split-data):
(org-protocol-parse-parameters):
* lisp/org.el (org-open-at-point):
(org-display-inline-images):
* lisp/ox-ascii.el (org-ascii-link):
* lisp/ox-html.el (org-html-link):
* lisp/ox-latex.el (org-latex--inline-image):
(org-latex-link):
* lisp/ox-publish.el (org-publish-resolve-external-link):
* lisp/ox.el (org-export-custom-protocol-maybe):
(org-export-resolve-fuzzy-link): Do not call `org-link-unescape' when
the link is obtained through the parser or as a user input.
* doc/org-manual.org (Link Format): Document escape syntax.

See <http://lists.gnu.org/r/emacs-orgmode/2019-02/msg00320.html>
2019-02-27 20:22:51 +01:00
Robert Klein
a50ced61ef Update tel link definition
* contrib/lisp/org-contacts.el ("contacts"):

Update to use org-link-set-parameters.
2016-08-08 11:10:04 +02:00
Nicolas Goaziou
f07048b75d Use string-match-p' instead of org-string-match-p'
* contrib/lisp/org-contacts.el (org-contacts-filter):
(org-contacts-complete-group):
(org-contacts-complete-tags-props):
* contrib/lisp/org-wl.el (org-wl-open):
* contrib/lisp/ox-bibtex.el (org-bibtex-merge-contiguous-citations):
* lisp/ob-core.el (org-babel-demarcate-block):
* lisp/ob-processing.el (org-babel-processing-view-sketch):
* lisp/ob-stan.el (org-babel-execute:stan):
* lisp/org-agenda.el (org-agenda-get-category-icon):
* lisp/org-clock.el (org-clock-into-drawer):
* lisp/org-element.el (org-element-link-parser):
* lisp/org-lint.el (org-lint-orphaned-affiliated-keywords):
(org-lint-invalid-babel-call-block):
(org-lint-colon-in-name):
* lisp/org-list.el (org-list-item-body-column):
* lisp/org-macro.el (org-macro-replace-all):
* lisp/org-plot.el (org-plot/gnuplot-script):
* lisp/org-table.el (org-table-export):
(org-table-align):
(org-table-get-range):
(org-table-recalculate):
(org-table-expand-lhs-ranges):
(org-table-formula-substitute-names):
(org-table-show-reference):
(orgtbl-to-texinfo):
(org-table-remote-reference-indirection):
* lisp/org.el (org-make-link-string):
(org--open-elisp-link):
(org-open-at-point):
(org-store-log-note):
(org-cached-entry-get):
(org--valid-property-p):
(org-entry-properties):
(org-buffer-property-keys):
(org-insert-drawer):
(org-display-inline-images):
(org-in-commented-heading-p):
* lisp/ox-ascii.el (org-ascii-keyword):
* lisp/ox-beamer.el (org-beamer--format-frame):
* lisp/ox-html.el (org-html-keyword):
* lisp/ox-latex.el (org-latex--label):
(org-latex-headline):
(org-latex-item):
(org-latex-keyword):
(org-latex--inline-image):
(org-latex-src-block):
* lisp/ox-odt.el (org-odt-styles-dir):
(org-odt-keyword):
(org-odt--translate-latex-fragments):
* lisp/ox-texinfo.el (org-texinfo-template):
(org-texinfo-keyword):
(org-texinfo-src-block):
* lisp/ox.el (org-export-inline-image-p):
(org-export-file-uri):
* testing/lisp/test-org-table.el (test-org-table/to-generic):
(test-org-table/to-latex):
(test-org-table/to-html):
(test-org-table/named-field):
(test-org-table/named-column):
(test-org-table/tab-indent):
(test-org-table/first-rc):
(test-org-table/last-rc): Use `string-match-p' instead of
`org-string-match-p'.
2016-07-25 15:21:12 +02:00
Nicolas Goaziou
0ec6917ed8 Deprecate org-no-warnings' in favor of with-no-warnings'
* lisp/org-macs.el (org-no-warnings): Rewove macro.
* lisp/org-compat.el (org-no-warnings): Mark `org-no-warnings' as
  obsolete.
* contrib/lisp/org-contacts.el (defvar):
* contrib/lisp/org-wl.el (org-wl-open):
* lisp/org-agenda.el (defvar):
(org-anniversary):
(org-cyclic):
(org-block):
(org-date):
* lisp/org-bbdb.el (defvar):
* lisp/org-clock.el (org-clock-out):
(org-clock-cancel):
* lisp/org-mouse.el (org-mouse-show-context-menu):
* lisp/org.el (org-modify-ts-extra):
(org-order-calendar-date-args): Small refactoring.
* lisp/ox-odt.el (org-odt-htmlfontify-string):
2016-06-23 15:20:32 +02:00
Nicolas Goaziou
4170ea25f3 Deprecate org-find-if' in favor of cl-find-if'
* lisp/org.el (org-find-if): Remove function.
(org-key):
* contrib/lisp/org-contacts.el (org-contacts-db-need-update-p):
(org-contacts-filter):
(org-contacts-test-completion-prefix):
(org-contacts-remove-ignored-property-values): Use `cl-find-if'
* lisp/org-compat.el (org-find-if): Mark function as an obsolete alias
  for `cl-find-if'.
2016-06-23 09:22:49 +02:00
Nicolas Goaziou
27bec00a60 org-agenda: Remove unnecessary visibility modification
* lisp/org.el (org-show-context-detail): Change default visibility span
  for agenda context.

* lisp/org-agenda.el (org-agenda-goto):
(org-agenda-todo):
(org-agenda-add-note):
(org-agenda-priority):
(org-agenda-set-tags):
(org-agenda-set-property):
(org-agenda-set-effort):
(org-agenda-toggle-archive-tag):
(org-agenda-clock-in): Special visibility is taken care of by
`org-show-context'.  Do not hard-code anything else.

* contrib/lisp/org-contacts.el (org-contacts-gnus-article-from-goto):
Special visibility is taken care of by `org-show-context'.  Do not
hard-code anything else.
2016-04-29 11:35:49 +02:00
Simon Thum
f02da8b4de org-contacts: Register "tel" link
This has the added benefit of not screwing up the exporter.

Signed-off-by: Simon Thum <simon.thum@gmx.de>
2016-02-25 10:14:25 +01:00
Nicolas Goaziou
60339bd55f Make `org-make-tags-matcher' lexical binding friendly
* lisp/org.el (org-make-tags-matcher): Return a function instead of
  a sexp.  Refactor code.
(org--matcher-tags-todo-only): New variable.  Replace `todo-only'
dynamic binding.
(org-scan-tags): Apply changes to `org-make-tags-matcher'.
(org-match-sparse-tree):
(org-map-entries): Use new variable.

* lisp/org-crypt.el (org-encrypt-entries):
(org-decrypt-entries): Use new variable.

* lisp/org-clock.el (org-clock-get-table-data): Apply changes to
  `org-make-tags-matcher'.

* lisp/org-agenda.el (org-tags-view): Use new variable.
2016-01-10 21:16:29 +01:00
Jan Malakhovski
2ec03e18b8 org-contacts: Fix org-contacts-matcher for BIRTHDAYs
* contrib/lisp/org-contacts.el (org-contacts-matcher): Fix expression to
  work for BIRTHDAY-only contacts.
2015-12-29 21:09:32 +01:00
Aaron Ecay
33c5e0582c contrib: move a few libraries to cl-lib in place of compile-time cl.
Specifically ob-julia, ob-stata, org-contacts, ox-bibtex.
2015-11-06 12:50:41 +00:00
Aaron Ecay
3fa42fb53f Remove some home-grown copies of cl-lib functions.
* lisp/org.el (org-count, org-remove-if, org-remove-if-not):
(org-reduce, org-every, org-some): Obsolete, use cl-lib versions
everywhere.
(org-sublist): Reimplement in terms of `cl-subseq'; make obsolete.
2015-11-06 12:50:40 +00:00
Philippe Crama
d1298f4599 org-contacts.el: Catch nextfile' in org-contacts-db'
* org-contacts.el (org-contacts-db): Catch `nextfile'.

When a file in the list returned by the `org-contacts-files' function
doesn't exist and the user selects the option to attempt to remove it
from the `org-agenda-files' list, 'nextfile is thrown.  Catch it and
skip processing that file instead of failing.

TINYCHANGE
2015-06-23 23:47:46 +02:00
Aaron Ecay
8078958995 contrib: Fix error messages.
* contrib/lisp/ob-eukleides.el (org-babel-execute:eukleides):
* contrib/lisp/ob-oz.el (org-babel-execute:oz):
* contrib/lisp/ob-tcl.el (org-babel-prep-session:tcl):
(org-babel-tcl-evaluate):
* contrib/lisp/org-contacts.el (org-contacts-view-send-email):
* contrib/lisp/org-drill.el (org-drill-hide-heading-at-point):
* contrib/lisp/org-mew.el (org-mew-search):
(org-mew-capture):
* contrib/lisp/org-toc.el (org-toc-forward):
* contrib/lisp/ox-freemind.el (org-freemind--build-node-contents): Fix
formatting of error messages.
2015-01-26 02:54:17 -05:00
Grégoire Jadi
c32dbab114 contrib/lisp/org-contacts.el: Allow the user to customize interactively the vcard export
* contrib/lisp/org-contacts.el (org-contacts-export-as-vcard): Wrap
  `org-contacts-export-as-vcard-internal' to prompt for the parameters
  when called interactively.
(org-contacts-export-as-vcard-internal): The old function
  `org-contacts-export-as-vcard'.

Thanks to Esben Stien for the suggestion.
2014-07-26 13:36:46 +09:00
Grégoire Jadi
75021a1fc2 contrib/lisp/org-contacts.el: Fix a bug when contacts don't have an email address
* contrib/lisp/org-contacts.el (org-contacts-complete-tags-props,
org-contacts-complete-group): Fix a bug when contacts don't have an
email address.
2014-07-13 19:34:27 +09:00
Grégoire Jadi
bd83216f38 contrib/lisp/org-contacts.el: Complete contacts using tags and properties
* contrib/lisp/org-contacts.el (org-contacts-complete-tags-props): New
function that allows the user to retrieve contacts based on tags and
properties.

(org-contacts-complete-functions): Add
org-contacts-complete-tags-props to the completion functions.

(org-contacts-tags-props-prefix): Prefix used to detect the
completion method wished.

Based on the idea and implementation of John Kitchin
2014-07-13 19:28:49 +09:00
Grégoire Jadi
74edb70b13 contrib/lisp/org-contacts.el: Factorize the construction of the database
* contrib/lisp/org-contacts.el (org-contacts-at-point): New function
  used to return the contact at point.
(org-contacts-db): Factorize the construction of the database using
`org-contacts-at-point' and fix a small typo.
2014-06-17 16:42:08 +09:00
Grégoire Jadi
36c6b30ec2 contrib/lisp/org-contacts.el: Add a hook to allow users to plug completion functions
* contrib/lisp/org-contacts.el (org-contacts-complete-functions): A
  hook that contains the list of functions used to complete contacts.
(org-contacts-message-complete-function): Use the new hook.

Suggested by John Kitchin.
2014-06-17 16:41:49 +09:00
Bastien Guerry
c1a17bf632 Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-07 14:19:03 +01:00
Bastien Guerry
fd0f42a1bc Update copyright years again.
Hint: copyright years are all updated in Emacs.
2014-01-07 14:18:17 +01:00
Bastien Guerry
4d41ad256d Merge branch 'maint'
Conflicts:
	contrib/lisp/org-favtable.el
2014-01-05 06:36:11 +01:00