1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-26 10:49:38 +00:00

org-export: Use eq' instead of equal' when possible

* contrib/lisp/org-export.el (org-export-data,
  org-export-footnote-first-reference-p,
  org-export-get-footnote-number, org-export-get-ordinal,
  org-export-get-loc, org-export-table-row-group,
  org-export-table-cell-starts-colgroup-p,
  org-export-table-cell-ends-colgroup-p,
  org-export-table-cell-address): Use `eq' instead of `equal' when
  possible.
* contrib/lisp/org-e-ascii.el (org-e-ascii-table-row):
* contrib/lisp/org-e-beamer.el (org-e-beamer-select-environment):
* contrib/lisp/org-e-html.el (org-e-html-footnote-section,
  org-e-html-latex-environment, org-e-html-paragraph): Use `eq'
  instead of `equal' when possible.
* contrib/lisp/org-e-latex.el (org-e-latex--get-footnote-counter):
* contrib/lisp/org-e-odt.el (org-e-odt-do-format-code,
  org-e-odt-footnote-def, org-e-odt-item, org-e-odt-latex-environment,
  org-e-odt-latex-fragment, org-e-odt-plain-list, org-e-odt-table,
  org-e-odt-enumerate-element): Use `eq' instead of `equal' when
  possible.

In particular, comparing elements shouldn't be done with `equal' since
they are circular lists.  On the other hand, using `eq' is fine if
they belong to the same tree.
This commit is contained in:
Nicolas Goaziou 2012-07-16 16:19:56 +02:00
parent 4a53af87de
commit 95cd07d058
7 changed files with 31 additions and 33 deletions

View File

@ -1623,14 +1623,13 @@ a communication channel."
(borders (org-export-table-cell-borders cell info)))
(concat
(when (and (memq 'left borders)
(equal (org-element-map
table-row 'table-cell 'identity info t)
cell)))
(eq (org-element-map
table-row 'table-cell 'identity info t)
cell)))
(make-string (+ 2 width) (string-to-char horiz))
(cond
((not (memq 'right borders)) nil)
((equal (car (last (org-element-contents table-row)))
cell)
((eq (car (last (org-element-contents table-row))) cell)
rcorner)
(t vert)))))
info)) "\n"))))

View File

@ -1018,7 +1018,7 @@ aid, but the tag does not have any semantic meaning."
(org-set-tags)
(let ((tags (or (ignore-errors (org-get-tags-string)) "")))
(cond
((equal org-last-tag-selection-key ?|)
((eq org-last-tag-selection-key ?|)
(if (string-match ":BMCOL:" tags)
(org-set-property "BEAMER_col" (read-string "Column width: "))
(org-delete-property "BEAMER_col")))

View File

@ -1311,7 +1311,7 @@ Replaces invalid characters with \"_\"."
(fn-alist
(loop for (n type raw) in fn-alist collect
(cons n (if (equal (org-element-type raw) 'org-data)
(cons n (if (eq (org-element-type raw) 'org-data)
(org-trim (org-export-data raw info))
(format "<p>%s</p>"
(org-trim (org-export-data raw info))))))))
@ -2275,9 +2275,9 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(attr nil) ; FIXME
(label (org-element-property :name latex-environment)))
(cond
((member processing-type '(t mathjax))
((memq processing-type '(t mathjax))
(org-e-html-format-latex latex-frag 'mathjax))
((equal processing-type 'dvipng)
((eq processing-type 'dvipng)
(let* ((formula-link (org-e-html-format-latex
latex-frag processing-type)))
(when (and formula-link
@ -2579,7 +2579,7 @@ the plist used as a communication channel."
(extra (if class (format " class=\"%s\"" class) ""))
(parent (org-export-get-parent paragraph)))
(cond
((and (equal (org-element-type parent) 'item)
((and (eq (org-element-type parent) 'item)
(= (org-element-property :begin paragraph)
(org-element-property :contents-begin parent)))
;; leading paragraph in a list item have no tags

View File

@ -1262,7 +1262,7 @@ INFO is a plist used as a communication channel."
(let ((fn-lbl (org-element-property :label fn)))
(cond
;; Anonymous footnote match: return number.
((equal fn footnote-reference) (length seen-refs))
((eq fn footnote-reference) (length seen-refs))
;; Anonymous footnote: it's always a new one.
;; Also, be sure to return nil from the `cond' so
;; `first-match' doesn't get us out of the loop.

View File

@ -2264,7 +2264,7 @@ This function shouldn't be used for floats. See
num-start refs))
(cond
((not num-start) code)
((equal num-start 0)
((eq num-start 0)
(org-e-odt-format-tags
'("<text:list text:style-name=\"OrgSrcBlockNumberedLine\"%s>"
. "</text:list>") code " text:continue-numbering=\"false\""))
@ -2480,7 +2480,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;;;; Footnote Reference
(defun org-e-odt-footnote-def (raw info) ; FIXME
(if (equal (org-element-type raw) 'org-data)
(if (eq (org-element-type raw) 'org-data)
(org-trim (org-export-data raw info)) ; fix paragraph style
(org-e-odt-format-stylized-paragraph
'footnote (org-trim (org-export-data raw info)))))
@ -2692,7 +2692,7 @@ contextual information."
(function
(lambda (element info)
(loop for el in (org-element-contents element)
thereis (equal (org-element-type el) 'table))))))
thereis (eq (org-element-type el) 'table))))))
(cond
((funcall --element-has-a-table-p item info)
"</text:list-header>")
@ -2781,7 +2781,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(cond
((member processing-type '(t mathjax))
(org-e-odt-format-formula latex-environment info))
((equal processing-type 'dvipng)
((eq processing-type 'dvipng)
(org-e-odt-format-stylized-paragraph
nil (org-e-odt-link--inline-image latex-environment info)))
(t latex-frag)))))
@ -2804,7 +2804,7 @@ CONTENTS is nil. INFO is a plist holding contextual information."
(cond
((member processing-type '(t mathjax))
(org-e-odt-format-formula latex-fragment info))
((equal processing-type 'dvipng)
((eq processing-type 'dvipng)
(org-e-odt-link--inline-image latex-fragment info))
(t latex-frag))))
@ -3137,7 +3137,7 @@ contextual information."
;; continue numbering.
(format "text:continue-numbering=\"%s\""
(let* ((parent (org-export-get-parent plain-list)))
(if (and parent (equal (org-element-type parent) 'item))
(if (and parent (eq (org-element-type parent) 'item))
"true" "false")))
contents))))
@ -3586,13 +3586,13 @@ contextual information."
(function
(lambda (element info)
(loop for el in (funcall --get-previous-elements element info)
thereis (equal (org-element-type el) 'table)))))
thereis (eq (org-element-type el) 'table)))))
(--walk-list-genealogy-and-collect-tags
(function
(lambda (table info)
(let* ((genealogy (org-export-get-genealogy table))
(list-genealogy
(when (equal (org-element-type (car genealogy)) 'item)
(when (eq (org-element-type (car genealogy)) 'item)
(loop for el in genealogy
when (member (org-element-type el)
'(item plain-list))
@ -4035,7 +4035,7 @@ using `org-open-file'."
(lambda (el)
(and (or (not predicate) (funcall predicate el info))
(incf counter)
(equal element el)
(eq element el)
counter))
info 'first-match)))))
(scope (funcall numbered-parent-headline-at-<=-n

View File

@ -3532,7 +3532,7 @@ Nil values returned from FUN do not appear in the results."
(cond
((not --data))
;; Ignored element in an export context.
((and info (member --data (plist-get info :ignore-list))))
((and info (memq --data (plist-get info :ignore-list))))
;; Secondary string: only objects can be found there.
((not --type)
(when (eq --category 'objects) (mapc --walk-tree --data)))

View File

@ -1775,7 +1775,7 @@ Return transcoded string."
;; might be misleading.
(when (eq type 'paragraph)
(let ((parent (org-export-get-parent data)))
(and (equal (car (org-element-contents parent))
(and (eq (car (org-element-contents parent))
data)
(memq (org-element-type parent)
'(footnote-definition item))))))))
@ -2806,7 +2806,7 @@ INFO is the plist used as a communication channel."
;; Don't enter footnote definitions since it will
;; happen when their first reference is found.
info 'first-match 'footnote-definition)))))
(equal (catch 'exit (funcall search-refs (plist-get info :parse-tree)))
(eq (catch 'exit (funcall search-refs (plist-get info :parse-tree)))
footnote-reference)))))
(defun org-export-get-footnote-definition (footnote-reference info)
@ -2835,7 +2835,7 @@ INFO is the plist used as a communication channel."
(let ((fn-lbl (org-element-property :label fn)))
(cond
;; Anonymous footnote match: return number.
((and (not fn-lbl) (equal fn footnote))
((and (not fn-lbl) (eq fn footnote))
(throw 'exit (1+ (length seen-refs))))
;; Labels match: return number.
((and label (string= label fn-lbl))
@ -3241,7 +3241,7 @@ objects of the same type."
(plist-get info :parse-tree) (or types (org-element-type element))
(lambda (el)
(cond
((equal element el) (1+ counter))
((eq element el) (1+ counter))
((not predicate) (incf counter) nil)
((funcall predicate el info) (incf counter) nil)))
info 'first-match))))))
@ -3282,7 +3282,7 @@ ELEMENT is excluded from count."
(lambda (el)
(cond
;; ELEMENT is reached: Quit the loop.
((equal el element) t)
((eq el element))
;; Only count lines from src-block and example-block elements
;; with a "+n" or "-n" switch. A "-n" switch resets counter.
((not (memq (org-element-type el) '(src-block example-block))) nil)
@ -3547,7 +3547,7 @@ rows and table rules. Group 1 is also table's header."
(unless row-flag (incf group) (setq row-flag t)))
((eq (org-element-property :type row) 'rule)
(setq row-flag nil)))
(when (equal table-row row) (throw 'found group)))
(when (eq table-row row) (throw 'found group)))
(org-element-contents (org-export-get-parent table-row)))))))
(defun org-export-table-cell-width (table-cell info)
@ -3737,7 +3737,7 @@ INFO is a plist used as a communication channel."
;; A cell starts a column group either when it is at the beginning
;; of a row (or after the special column, if any) or when it has
;; a left border.
(or (equal (org-element-map
(or (eq (org-element-map
(org-export-get-parent table-cell)
'table-cell 'identity info 'first-match)
table-cell)
@ -3748,7 +3748,7 @@ INFO is a plist used as a communication channel."
INFO is a plist used as a communication channel."
;; A cell ends a column group either when it is at the end of a row
;; or when it has a right border.
(or (equal (car (last (org-element-contents
(or (eq (car (last (org-element-contents
(org-export-get-parent table-cell))))
table-cell)
(memq 'right (org-export-table-cell-borders table-cell info))))
@ -3822,7 +3822,7 @@ function returns nil for other cells."
;; Ignore cells in special rows or in special column.
(unless (or (org-export-table-row-is-special-p table-row info)
(and (org-export-table-has-special-column-p table)
(equal (car (org-element-contents table-row)) table-cell)))
(eq (car (org-element-contents table-row)) table-cell)))
(cons
;; Row number.
(let ((row-count 0))
@ -3830,7 +3830,7 @@ function returns nil for other cells."
table 'table-row
(lambda (row)
(cond ((eq (org-element-property :type row) 'rule) nil)
((equal row table-row) row-count)
((eq row table-row) row-count)
(t (incf row-count) nil)))
info 'first-match))
;; Column number.
@ -3838,8 +3838,7 @@ function returns nil for other cells."
(org-element-map
table-row 'table-cell
(lambda (cell)
(if (equal cell table-cell) col-count
(incf col-count) nil))
(if (eq cell table-cell) col-count (incf col-count) nil))
info 'first-match))))))
(defun org-export-get-table-cell-at (address table info)