Git Product home page Git Product logo

Comments (10)

tmalsburg avatar tmalsburg commented on June 12, 2024

Sounds interesting. It would make things easier if tags were stored in the BibTeX file, e.g., in the field for keywords or a new field. This way it would be trivial to implement the search part of your proposal (except perhaps for the hierarchy bit; not sure if I understand what you mean there). Editing tags should also be easy to implement. Generating an index would probably better be handled by a separate tool. That could be implemented using bib2bib, bibtex2html, and some shell-script glue. I use a similar setup to generate the sections of my publication page.

from helm-bibtex.

paul-g avatar paul-g commented on June 12, 2024

Is it safe to add another field or could it affect other tools that process bibtex files?
If it's safe an option would be to use the keywords field as content tags and then another field (tags) for the read/unread/favourite tags.

Could the latter be displayed as a separate column in the results?

from helm-bibtex.

tmalsburg avatar tmalsburg commented on June 12, 2024

It's safe to add fields and many bibliography managers do it for their own internal purposes. I agree that we should not pollute the keywords field with tags. Customization of columns is desirable and not too difficult to implement. However, it's not too high up on my list of priorities. I'm happy to accept pull requests, though. Mu4e has customizable columns and perhaps it would make sense to copy the way they define the columns.

from helm-bibtex.

paul-g avatar paul-g commented on June 12, 2024

OK. I'll send a pull request when I get to it :)

from helm-bibtex.

tmalsburg avatar tmalsburg commented on June 12, 2024

I started working on this by introducing a tags field in my bibliography. Now I have data for testing. I think we should break this down in several separate feature additions (and pull requests):

  1. Add the ability to configure which fields are used for searching. Other people may already have a field for tags and we don't want to force them to use the name "tags". Of course configurable search fields are useful for independent reasons as well.
  2. Configurable columns for display of search results (probably mu4e style).
  3. Configure tags field and add the possibility to edit tags.

Not sure, whether the last point is needed. I think I would prefer to just edit the BibTeX entry using the "show extry" action (which should perhaps be renamed to "edit entry").

from helm-bibtex.

tmalsburg avatar tmalsburg commented on June 12, 2024

I added code to address 1 (2ddea19). Now you can add this to your configuration to extend the fields that are used for searching by the field tags:

(setq helm-bibtex-additional-search-fields '(tags))

However, tags are not displayed and there is no special UI for editing them. Not sure whether I will add code for the latter because my approach is to edit BibTeX directly.

from helm-bibtex.

paul-g avatar paul-g commented on June 12, 2024

Nice! I experimented a bit to see what tags I would find useful and I came to the following conclusion:

  1. Use the tags field to mark items which are read/in progress/to read
  2. Use an additional field cites to mark interesting references of this paper. This way I can use a simple script like this to print a graph of my reading list straight from the bib file

As you say, I found that editing the bib file directly is the way to go. With that in mind, I thought it would be nice to have some functions that jump directly to tags or cites fields (when present). The patch is here but needs merging with your latest commit.

from helm-bibtex.

tmalsburg avatar tmalsburg commented on June 12, 2024

Hi Paul, your cites field is a cool idea but I suppose you are the only user of that field and I don't want to add non-standard functionallity that is used by only one user. Similarly, tags is a non-standard field that is perhaps only used by you and me. Having said that, it might make sense at some point to add infrastucture that allows users to introduce custom fields and edit actions for these fields without having to mess with the code. Since the main feature that you requested (seraching for tags) was added, I'll close this issue for now.

from helm-bibtex.

eeenilsson avatar eeenilsson commented on June 12, 2024

Thanks for adding tags! I wrote a function to tag multiple entries, if someone has use for it. Requires org-ref.

;;** Add tags interactively to bibtex entry in .bib file, also sorting fields
(defun bibtex-completion-tag-entry (keys)
  "Tag multiple bibtex entries in .bib file."
  (interactive)
;; Using a modified version of org-ref-sort-bibtex-entry.
  
  ;; Input tag
  (setq enteredTag (read-string "Enter tag:"))
  
  (dolist (tempKey keys) ;; to enable tagging of multiple entries
    
    ;; "Show the selected entry in the BibTeX file."
    (catch 'break
      (dolist (bib-file (bibtex-completion-normalize-bibliography 'main))
	(let ((key tempKey)
	      (buf (bibtex-completion-buffer-visiting bib-file)))
	  (find-file bib-file)
	  (widen)
	  (if (eq major-mode 'org-mode)
	      (let* ((prop (if (boundp 'org-bibtex-key-property)
			       org-bibtex-key-property
			     "CUSTOM_ID"))
		     (match (org-find-property prop key)))
		(when match
		  (goto-char match)
		  (org-show-entry)
		  (throw 'break t)))
	    (goto-char (point-min))
	    (when (re-search-forward
		   (concat "^@\\(" parsebib--bibtex-identifier
			   "\\)[[:space:]]*[\(\{][[:space:]]*"
			   (regexp-quote key) "[[:space:]]*,") nil t)
	      (throw 'break t)))
	  (unless buf
	    (kill-buffer)))))

    ;; retrieve entry as list
    (bibtex-beginning-of-entry)
    (let* (
	   (entry (bibtex-parse-entry))
	   (entry-fields)
	   (other-fields)
	   (addTag enteredTag)
	   (oldTags (cdr (assoc "tags" entry))) ;; to keep existing tags
	   (type (cdr (assoc "=type=" entry)))
	   (key (cdr (assoc "=key=" entry)))
	   (field-order (cdr (assoc (if type (downcase type))
				    org-ref-bibtex-sort-order))))
      
      ;; if tags are not nil keep old tags and add the new one
      (if (cdr (assoc "tags" entry))
	  (setcdr (assoc "tags" entry)
		  (s-concat (replace-regexp-in-string "}" ", " (format "%s" oldTags)) addTag "}"))
	)

      ;; if tags are nil, add the new tag, then santize
      (if
	  (cdr (assoc "tags" entry)) nil (push (list "tags" addTag) entry);; create tag if nil
	  ;; sanitize, changing parenteses to curly braces
	  (setcdr (assoc "tags" entry) (s-concat (replace-regexp-in-string ")" "}" (format "%s" (cdr (assoc "tags" entry))))))
	  (setcdr (assoc "tags" entry) (s-concat (replace-regexp-in-string "(" "{" (format "%s" (cdr (assoc "tags" entry))))))
	  )

      ;; these are the fields we want to order that are in this entry
      (setq entry-fields (mapcar (lambda (x) (car x)) entry))
      ;; we do not want to reenter these fields
      (setq entry-fields (remove "=key=" entry-fields))
      (setq entry-fields (remove "=type=" entry-fields))

      ;;these are the other fields in the entry, and we sort them alphabetically.
      (setq other-fields
	    (sort (-remove (lambda(x) (member x field-order)) entry-fields)
		  'string<))

      (bibtex-kill-entry)
      (insert
       (concat "@" type "{" key ",\n"
	       (mapconcat
		(lambda (field)
		  (when (member field entry-fields)
		    (format "%s = %s,"
			    field
			    (cdr (assoc field entry)))))
		field-order "\n")
	       ;; now add the other fields
	       (mapconcat
		(lambda (field)
		  (cl-loop for (f . v) in entry concat
			   (when (string= f field)
			     (format "%s = %s,\n" f v))))
		(-uniq other-fields) "\n")
	       "\n}\n\n"))
      (bibtex-find-entry key)
      (bibtex-fill-entry)
      (bibtex-clean-entry))
    )
  )

from helm-bibtex.

tmalsburg avatar tmalsburg commented on June 12, 2024

Thanks for sharing this. When I have some time I will consider adding this as a standard feature.

from helm-bibtex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.