From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: custom emacs org-emphasis-alist breaks EXPORT, help ;-) ? Date: Mon, 04 Nov 2013 12:03:46 +0800 Message-ID: <87iow8ak4d.fsf@ericabrahamsen.net> References: <87r4c1mrh1.fsf@bzg.ath.cx> <87d2nlzcoo.fsf@bzg.ath.cx> <878uy99z28.fsf@ericabrahamsen.net> <87r4c08h21.fsf@ericabrahamsen.net> <87wqlr6ld5.fsf@ericabrahamsen.net> <8761sbkt3q.fsf@ericabrahamsen.net> <878ux6azoe.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdBNC-0000HJ-5a for emacs-orgmode@gnu.org; Sun, 03 Nov 2013 23:02:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VdBN6-00075u-0I for emacs-orgmode@gnu.org; Sun, 03 Nov 2013 23:02:42 -0500 Received: from plane.gmane.org ([80.91.229.3]:39532) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VdBN5-00075q-Mf for emacs-orgmode@gnu.org; Sun, 03 Nov 2013 23:02:35 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VdBN3-0004n6-Qh for emacs-orgmode@gnu.org; Mon, 04 Nov 2013 05:02:33 +0100 Received: from 114.248.26.151 ([114.248.26.151]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Nov 2013 05:02:33 +0100 Received: from eric by 114.248.26.151 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 04 Nov 2013 05:02:33 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Xebar Saram writes: > Thank you Eric and Jambunathan > > Eric: i tried with the added backslash but that dosent seem to work > as well, would you mind testing the snippet below on your system? is > it still something wrong im doing? > > ;test > (font-lock-add-keywords > 'org-mode > '(("\\b[Ss]alt\\b)" (0 '(:weight ultra-bold :foregroun "#FF9800") > t)))) What!? You mean I should actually test my suggestions!? :) You've got one more typo I didn't see -- there's a spurious close parenthesis at the end of the regexp, just inside the quote. I promise I actually tried it this time, and taking that parenthesis out works! E > Jambunathan:  hi-lock-mode looks interesting and i will investigate > it soon, is it per file settings, or can you define a word/fg-bg rule > that will apply to all files? > > thanks alot guys, really appreciate it! > > > > On Sun, Nov 3, 2013 at 6:15 AM, Eric Abrahamsen < > eric@ericabrahamsen.net> wrote: >> >> Xebar Saram writes: >> >> > Thanks Eric , really appreciate the continuous help! >> > >> > i do plan to get into rexeg on the future (i promise :)) but real >> > life now just allow me to allocate time (i started an assistant >> > professor position and time is at a huge premium..). >> > >> > i tried using this as i tried to understand from your email, but > i >> > guess im again doing something wrong. shouldn't the below example >> > color "salt", it dosent see to work. >> > >> > ;test >> > (font-lock-add-keywords >> >  'org-mode >> > '(("\b[Ss]alt\\b)" (0 '(:weight ultra-bold :foregroun "#FF9800") >> > t)))) >> >> Looks like you're missing a backslash at the beginning of the > regexp -- >> make sure it reads "\\b... >> >> E >> >> > thank you for all your help >> > >> > >> > >> > On Sat, Nov 2, 2013 at 12:15 PM, Eric Abrahamsen < >> > eric@ericabrahamsen.net> wrote: >> > >> >     Xebar Saram writes: >> > >> >     > Hi again all >> >     > >> >     > i have been using the before discussed font lock with great >> >     success >> >     > over the past few weeks, thx alot for that tip! >> >     > >> >     > one short question i have from using it thourhgly is > weather >> >     its >> >     > possible to color specific words , IE not just text bound >> >     between >> >     > symbols ( ie > !text! ) but rather lets say i always want > to >> >     make the >> >     > word server appear with blue FG. is this possible? > currently i >> >     tried >> >     > >> >     > (font-lock-add-keywords >> >     >  'org-mode >> >     > '(("\\(server[^server\n]+server\\)" (0 '(:foreground "# > 000000" >> >     > :underline t :background "#FF9AEA" :weight ultra-bold) > t)))) >> > >> >     At some point you're definitely going to want to read up on >> >     regular >> >     expressions! >> > >> >     But in the meantime yes, it's entirely (mostly) possible. A >> >     regular >> >     expression is just a way of finding desired pieces of text in > a >> >     larger >> >     run of text. Think of the regexp as an instruction that > starts: >> >     "Find >> >     all pieces of text that are..." >> > >> >     All the special regexp characters are just a way of making > the >> >     instruction general (_any_ number, four of _any_ character, >> >     _anything_ >> >     that's not a "p"). >> > >> >     In the most basic case, however, a regexp is simply the text > you >> >     want to >> >     find: "Find all pieces of text that are 'server'". In this > case, >> >     that's >> >     your regexp: "server". >> > >> >     The reason regexps are difficult, of course, is that they > can't >> >     read >> >     your mind, and will find things you didn't want, and not find >> >     things you >> >     did want. So much of messing with regexps is telling them: > _yes_ >> >     this >> >     too, _no_ not that. In your case, you'd probably want to put > word >> >     boundaries around the regexp ("\b" on either side), and find > both >> >     capitalized and lowercase instances of the word. So your >> >     instruction >> >     might be: >> > >> >     "Find all pieces of text that are 'server' or 'Server', but > only >> >     as a >> >     complete word." >> > >> >     Which would look like >> > >> >     "\\b[Ss]erver\\b" >> > >> >     Give that a shot. You're jumping into the middle of something >> >     fairly >> >     complicated, so be patient and go slow! >> > >> >     E >> > >> >     > instead of the original >> >     > >> >     > (font-lock-add-keywords >> >     >  'org-mode >> >     > '(("\\(₆[^₆\n]+₆\\)" (0 '(:foreground "#000000" :underline > t >> >     > :background "#FF9AEA" :weight ultra-bold) t)))) >> >     > >> >     > >> >     > again i apologize for my regrex ignorance :) >> >     > >> >     > best >> >     > >> >     > Z >> >     > >> >     > >> >     > >> >     > >> >     > On Sun, Oct 6, 2013 at 8:04 AM, Eric Abrahamsen < >> >     > eric@ericabrahamsen.net> wrote: >> >     > >> >     >     Xebar Saram writes: >> >     > >> >     >     > thx again Eric >> >     >     > >> >     >     > i still have an issue with this when one of the > symbols >> >     used to >> >     >     start >> >     >     > /end the highlight is used in a sentence, for example >> >     using >> >     >     your >> >     >     > code: >> >     >     > >> >     >     > (font-lock-add-keywords >> >     >     >  'org-mode >> >     >     >  '(("-1-\\([^-1-]+\\)-1-" (0 '(:weight ultra-bold >> >     :background " >> >     >     # >> >     >     > DDFFDD" :foreground "#000000") t)))) >> >     >     > >> >     >     > if i write this: >> >     >     > >> >     >     > -1- this is a test of 1x1 to show higlight -1- >> >     >     > >> >     >     > it will kill the highlight, if i use the same text >> >     omitting the >> >     >     '1' >> >     >     > it works well, anyway around this issue? i thought it >> >     would >> >     >     have >> >     >     > matcehd -1- but it seems it matches also just 1 by > itself >> >     >     > >> >     >     > best wishes and thx again >> >     > >> >     >     Yup, the things inside the [^] construct, to _not_ be >> >     matched, >> >     >     are >> >     >     treated as a list of single characters. So you're > saying >> >     >     "anything >> >     >     that's not a '1' or a '-'," but then you've got a '1' > in >> >     the >> >     >     middle of >> >     >     the line. If you want the highlighting to include any >> >     character, >> >     >     but not >> >     >     span newlines, you could just use [^\n] instead. >> >     > >> >     >     At this point you'll probably want to read the regular >> >     expression >> >     >     part >> >     >     of the manual: >> >     > >> >     >     (elisp) Regular Expressions >> >     > >> >     >     I think you mentioned you don't have a lot of > programming >> >     >     experience. >> >     >     That's a bit unfortunate, since regexps aren't a great >> >     place to >> >     >     start! >> >     >     I'd recommend getting something that's "close enough", > and >> >     not >> >     >     going >> >     >     down the rabbit hole of perfect. Then start at the top > of >> >     the >> >     >     introduction to elisp... >> >     > >> >     >     Good luck, >> >     >     Eric >> >     > >> >     > >> > >> > >> >>