Skip to main content
added 30 characters in body
Source Link
Gabriele
  • 1.7k
  • 11
  • 22

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
        (let ((b (match-beginning 1))
              (e (match-end 1)))
          (put-text-property b e SOMETHING))))))
(defun propertize-command-arg ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
        (let ((b (match-beginning 1))
              (e (match-end 1)))
          (put-text-property b e SOMETHING))))))

SOMETHING is what I've not be able to understand/find. I tried also add-text-properties and add-face-text-property.

Please keep in mind I need to do it temporarily. I'll restore the original appearance of the text at the end of my job (script).

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
        (let ((b (match-beginning 1))
              (e (match-end 1)))
          (put-text-property b e SOMETHING))))))

SOMETHING is what I've not be able to understand/find. I tried also add-text-properties and add-face-text-property.

Please keep in mind I need to do it temporarily. I'll restore the original appearance of the text at the end of my job (script).

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
        (let ((b (match-beginning 1))
              (e (match-end 1)))
          (put-text-property b e SOMETHING))))))

SOMETHING is what I've not be able to understand/find. I tried also add-text-properties and add-face-text-property.

Please keep in mind I need to do it temporarily. I'll restore the original appearance of the text at the end of my job (script).

deleted 50 characters in body
Source Link
Drew
  • 79.1k
  • 10
  • 123
  • 257

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion
 
    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
        (let ((b (match-beginning 1))
              (e (match-end 1)))
          )
        (put-text-property b e SOMETHING)
      )))
    )
  )

The "SOMETHING" stuffSOMETHING is what I've not be able to understand/find. I tried also the add-text-properties and add-face-text-property.

Please, keep in mind I need to do it temporarily. I'll restore the original appeareanceappearance of the text at the end of my job (script).

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion
 
    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
    (let ((b (match-beginning 1))
          (e (match-end 1))
          )
        (put-text-property b e SOMETHING)
      )))
    )
  )

The "SOMETHING" stuff is what I've not be able to understand/find. I tried also the add-text-properties and add-face-text-property.

Please, keep in mind I need to do it temporarily. I'll restore the original appeareance of the text at the end of my job (script).

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
        (let ((b (match-beginning 1))
              (e (match-end 1)))
          (put-text-property b e SOMETHING))))))

SOMETHING is what I've not be able to understand/find. I tried also add-text-properties and add-face-text-property.

Please keep in mind I need to do it temporarily. I'll restore the original appearance of the text at the end of my job (script).

deleted 3 characters in body
Source Link
Gabriele
  • 1.7k
  • 11
  • 22

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion

    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
    (let ((b (match-beginning 1))
          (e (match-end 1))
          )
        (put-text-property b e SOMETHING)
      )))
    )
  )

The "SOMETHING" stuff is what I've not be able to to understand/find. I tried also the add-text-properties and add-face-text-property.

Please, keep in mind I need to do it temporarily. I'll restore the original appeareance of the text at the end of my job (script).

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion

    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
    (let ((b (match-beginning 1))
          (e (match-end 1))
          )
        (put-text-property b e SOMETHING)
      )))
    )
  )

The "SOMETHING" stuff is what I've not be able to to understand/find. I tried also the add-text-properties and add-face-text-property.

Please, keep in mind I need to do it temporarily. I'll restore the original appeareance of the text at the end of my job (script).

I need to change the "OBJECT" string foreground color (let's say "red") in all the occurrences of the string "\command{OBJECT}" in my buffer and I need to restore the original foreground color at the end of the job.

I figured out to do something like (it's a simplified MWE):

(defun propertize-command-arg ()
  (interactive)
  (save-excursion

    (goto-char (point-min))
    (while (search-forward-regexp "\\\\command{\\([a-z]+\\)}" nil t)
      (save-excursion
    (let ((b (match-beginning 1))
          (e (match-end 1))
          )
        (put-text-property b e SOMETHING)
      )))
    )
  )

The "SOMETHING" stuff is what I've not be able to understand/find. I tried also the add-text-properties and add-face-text-property.

Please, keep in mind I need to do it temporarily. I'll restore the original appeareance of the text at the end of my job (script).

edited tags
Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Loading
Source Link
Gabriele
  • 1.7k
  • 11
  • 22
Loading