texts: Syntax highlight strings in compilation-mode

texts:
Is it possible to activate syntax highlighting for strings in compilation mode?

Sometimes the compilation error output of some C++ linter is quite unreadable. Lengthy types and function definitions are printed with some small explanation in between. For example:

  foo.cpp:147:60: info 1764: parameter 'foo' of type '`NamespaceA::NamespaceB::NamespaceC::CFoo &' of function 'NamespaceA::NamespaceB::NamespaceC::CBar::setAs(const unsigned int, const NamespaceX::NamespaceY::CFoobar &, const NamespaceX::NamespaceZ::Cbarbaz &, NamespaceA::NamespaceB::NamespaceC::CFoo &, const NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &)' of type '_Bool (unsigned int, const NamespaceX::NamespaceY::CNamespaceY &, const NamespaceX::NamespaceZ::Cbarbaz &, NamespaceA::NamespaceB::NamespaceC::CFoo &, const NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &)' could be reference to const

If those '' strings would be highlighted with font-lock-string-face, then the relevant information could be spotted more easily.

  foo.cpp:147:60: info 1764: parameter 'foo' of type 'NamespaceA::NamespaceB::NamespaceC::CFoo &' of function 'NamespaceA::NamespaceB::NamespaceC::CBar::setAs(const unsigned int, const NamespaceX::NamespaceY::CFoobar &, const NamespaceX::NamespaceZ::Cbarbaz &, NamespaceA::NamespaceB::NamespaceC::CFoo &, const NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &)' of type '_Bool (unsigned int, const NamespaceX::NamespaceY::CNamespaceY &, const NamespaceX::NamespaceZ::Cbarbaz &, NamespaceA::NamespaceB::NamespaceC::CFoo &, const NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &, NamespaceA::NamespaceB::NamespaceC::CFoo &)' could be reference to const

Is there a way to activate that? Could it probably be done by changing the syntax-table used by compilation mode (if that is used)?

Or is there a minor mode available that I could activate?


texts: Using a common set of abbreviation for multiple major modes

texts:
I use multiple programming languages, and there are a considerable number of abbreviations that I use across all of their corresponding major mode (they are usually name of certain variables, but not limited to this category). One way of customizing Emacs is as follows: As explained here one needs to this in an Elisp file (see the example below) and load it in the init file.
Example Elisp file for storing the abbreviations (ignore that the syntax for the specified languages is not correct):
(when (boundp 'python-mode-abbrev-table)
  (clear-abbrev-table python-mode-abbrev-table))

(define-abbrev-table 'python-mode-abbrev-table

    ("p" "fmt.Printf(\"%v\\n\", hh▮)")
    ("pl" "fmt.Println(hh▮)")
    ("r" "return")
    ("st" "string")
    ("eq" "==")
    ("v" "var x = 3")
    ("df" "x := 3")
    ("c" "const x = 3")
    ))

(when (boundp 'matlab-mode-abbrev-table)
  (clear-abbrev-table matlab-mode-abbrev-table))

(define-abbrev-table 'matlab-mode-abbrev-table

    ("p" "fmt.Printf(\"%v\\n\", hh▮)")
    ("pl" "fmt.Println(hh▮)")
    ("r" "return")
    ("st" "string")
    ("eq" "==")
    ("v" "var x = 3")
    ("df" "x := 3")
    ("c" "const x = 3")
    ))

(set-default 'abbrev-mode t)

(setq save-abbrevs nil)

But then if you want to expand the list, you need to copy them for abbreviation of all major mode. Is there any way that I maintain only one list, and somehow call them for the needed major modes (maybe the solution is something like the \input{} in latex).
By the way, I prefer not to use the solution proposed here, as the usual/traditional way to set up abbreviations in Emacs was not very efficient for me (of course if I don't manage to find any other way I may have to use it).
Furthermore, each major mode can have its own abbrev table on top of the common one. In particular, I don't want any of the major modes to inherit all the abbreviations used in other modes (because language syntax is different in each language). Ideally, I'm trying to have something like this (I don't know any Elisp syntax, so ignore!):
;; Common ones
(when (boundp 'python-mode-abbrev-table OR matlab-mode-abbrev-table)

(define-abbrev-table 'python-mode-abbrev-table AND matlab-mode-abbrev-table

    ("p" "fmt.Printf(\"%v\\n\", hh▮)")
    ("pl" "fmt.Println(hh▮)")
    ("r" "return")
    ("st" "string")
    ("eq" "==")
    ("v" "var x = 3")
    ("df" "x := 3")
    ("c" "const x = 3")
    ))

;; Python specific ones
(when (boundp 'python-mode-abbrev-table)

(define-abbrev-table 'python-mode-abbrev-table

    ("p" "fmt.Printf(\"%v\\n\", hh▮)")
    ("pl" "fmt.Println(hh▮)")
    ))

;; MATLAB specific ones
(when (boundp 'matlab-mode-abbrev-table)

(define-abbrev-table 'matlab-mode-abbrev-table

    ("p" "fmt.Printf(\"%v\\n\", hh▮)")
    ("pl" "fmt.Println(hh▮)")
    ))

(set-default 'abbrev-mode t)

(setq save-abbrevs nil)

I'm new to Emacs (and this is the first time posting here), so sorry if the question and the way I phrase it is too naive!


texts: How can I make multiple calls to external binaries?

texts:
I want to write an interactive function to

Call an external binary
Write the output of the binary into a buffer
Process the buffer to extracts args for next call
Call another external binary using args
Display output of second call

Step 3 should only be called after step 2 is complete.

How can I do this?


texts: Adding links to locally stored images with a description to an org file

texts:
I am trying to insert images into an org-file using absolute paths (which include spaces) and a description, and then export them to PDF via LaTeX.
I am entering the link using C-c C-l, which should deal with the spaces itself, and I have tried it with and without the file: prefix - although that shouldn't make a difference.
I have also tried inserting the link by selecting the file through emacs itself, using C-u C-c C-l, but the results is the same.
I have also tried changing the path to escape the spaces, and using a URL style path, all to no avail.
The closest thing I can get to a solution so far is to not include a description, e.g. [[[file:path/to/file.png]]], which does insert the image, however it also inserts the full path as text, wrapped around the image.
Attempts so far:
Base link: /Home/Images/Emojis once extracted/example.png
[[file:/Home/Images/Emojis once extracted/example.png][Test1]]

[[file:/Home/Images/Emojis\ once\ extracted/example.png][Test2]]

[[/Home/Images/Emojis\ once\ extracted/example.png][Test3]]

[[file:///Home/Images/Emojis%20once%20extracted/example.png][Test4]]

[[file:/Home/Images/Emojis\ once\ extracted/example.png]]    ## Test5

Here is a preview of the org buffer:

I have org-version 8.2.10 running in Emacs 24.5
Edit 1:
Using the org function C-u C-c C-l (universal add link), and with no description, the image is placed in the pdf. However, if there are any spaces in the link to that file, then all characters following that space are also  inserted to the pdf alongside the image.
Here is an example of the PDF output from this line of code in the org file:
#CAPTION: A funny image
[[file:/path/to_file 4.png]]

Edit 2:
If I escape the spaces in the path, there is an error (found in buffer: *Org PDF LaTeX Output*, which is a package error, but says it cannot find the image and the following is produced in the PDF output:

Edit 3:
@John Kitchin 's answer below worked well for me. I also came across a customisation of his for drag-n-drop functionality that also solves this problem and adds even better functionality. I recommend people check out the full-description  with code and the accompanying video!


texts:
After upgrading to Emacs 25, I get gnutls-negotiate: Certificate validation failed for [hostname] verification code 402 on connecting to my weechat IRC proxy, with no prompt about accepting things anyway. I already have

(add-to-list 'gnutls-trustfiles "~/.emacs.d/weechat-relay.cert")

where weechat-relay.cert is the CERTIFICATE part of the weechat IRC proxy ssl key.


texts:
I am trying to export an org-beamer file to pdf. I have references that I inserted them by using org-ref. I can see some of my references in the last page but not all them because they do not fit into a single page (or frame).

How can I show all my references ?

B.R.


texts: how to discard a change in magit from spacemacs

texts:
In a normal emacs (not spacemacs), discard change is bound to key of "k", then in spacemacs, base on the following information.

http://spacemacs.org/doc/DOCUMENTATION.html

On the other hand, anything originally bound to k will be found on K, since k is reserved but K is not. If there is a binding on K, that will be moved to C-k.

But when I press K, it pops us a helm buffer to let me select a file to ingore in git.


texts: Function to paste killring after the current line (like "p" in vim)

texts:
I'm trying to write a very simple function to replicate the Vim 'p' command.
This is, paste some text after the current line.

I've been googling for a while and haven't found a function to achieve this, which I think it's very strange as I consider this quite handy!

I'm aware of the awesome Evil-mode, but I just require only this functionality to be happy :-)

So far this is what I have:

(defun paste-after-line ()
  (interactive)
  (prelude-smart-open-line nil) ;; This function opens a new line below
  (yank))

It works, but if the copied text has a line ending, then the yanked text also adds an empty line below the text and places the cursor there.

Does anyone knows if is there a way to yank some text excluding any new line on it?

Thanks!


texts: How to clear underlines after disabling flyspell?

texts:
There are already questions on disabling flyspell (see: https://stackoverflow.com/questions/3423638)

However I would like to toggle flyspell at runtime.

An annoyance I've found is the red-underline persists, even once flyspell has been disabled.

Closing and opening the file refreshes, but that's impractical.

eg:

(turn-off-flyspell)
(flyspell-mode 0)

;; force refresh of highlighting (doesn't work)
(font-lock-fontify-buffer)

Is there a way to clear underlined text?


texts: Coloring mu4e headers based on title content

texts:
I'd like to color the messages in my *mu4e-headers* view, depending on which mailing list they come from. I'm rather new to emacs face alterations, and I didn't see anything that looked relevant for this. Are there programmatic hooks for defining a per-line face?

Example: If an email is in my INBOX/ML folder, I'd like it green. If it's just in my INBOX, I'd like it blue.


texts: How can I have the latest version of emacs always

texts:
I love using Emacs and I want to have the latest version of Emacs always. But on my Ubuntu machine Emacs won't be upgraded automatically during the regular software updates. Even when I run sudo apt-get upgrade emacs it says I have the latest Emacs while I don't. I see I am using 24.4 version of Emacs while the latest one is 24.5.

I have searched for ways to upgrade Emacs to the latest version but I couldn't find any. Can you please tell me how to do that?


texts: Create a custom block in org-mode that exports to latex and html

texts:
I'm writing a long research org-mode document that I want to export to both LaTeX, ODT and HTML. The most important export environment is to LaTeX.

I would like to be able to specify an environment inside the org-mode document without specifying the language. For instance, I could write:

#+latex: \begin{acknowledgement}
...
#+latex: \end{acknowledgement}

But I would prefer to write something like:

#+begin_acknowledgement
..
#+end_acknowledgement

Is this possible?


texts:
I'm trying to capture stderr separately from stdout for a (synchronous) process run from emacs. I've found one way of doing it based on some code copied from emacs' shell-command function (I don't want to use shell-command directly because there is no need for a shell and shell-command puts stdout into a buffer):

(defun helm-dash-sql (db-path sql)
  "Run the sql command, parse the results and display errors"
  (helm-dash-parse-sql-results
   (with-output-to-string
     (let ((error-file (make-temp-file "helm-dash-errors-file")))
       (call-process "sqlite3" nil (list standard-output error-file) nil
                     ;; args for sqlite3:
                     db-path sql)

       ;; display errors, stolen from emacs' `shell-command` function
       (when (and error-file (file-exists-p error-file))
         (if (< 0 (nth 7 (file-attributes error-file)))
             (with-current-buffer (get-buffer-create "*helm-dash-errors*")
               (let ((pos-from-end (- (point-max) (point))))
                 (or (bobp)
                     (insert "\f\n"))
                 ;; Do no formatting while reading error file,
                 ;; because that can run a shell command, and we
                 ;; don't want that to cause an infinite recursion.
                 (format-insert-file error-file nil)
                 ;; Put point after the inserted errors.
                 (goto-char (- (point-max) pos-from-end)))
               (display-buffer (current-buffer))))
     (delete-file error-file))))))

However I suspect it could be done better in two ways:

It seems like this should be a solved problem and emacs should have a function that just "does the right thing" with stderr, but I can't find one. Is there such a function?
Every time a process is run shell-command creates (and later deletes) a temp file in which to store stderr. We are slightly concerned that this could have a performance impact because multiple processes are run for every keypress while inside this helm command. Is this likely to be an issue, and if so what is the best way around it?

For anyone curious: this is for helm-dash. The exact code I'm currently using is in this pull-request.


texts: How can I add a new colon-command to Evil?

texts:
evil-mode introduces vim-style colon commands (such as :wq to save and close).

I have a few commands (such as kill-buffer, org-babel-tangle) that I'd like to be able to run through this instead of the keybindings they currently have.

How can I add colon-commands like :k for kill-buffer and :tangle for org-babel-tangle?


texts:
I am having some strange problem regarding elpy-goto-definition (and some other features) and the use of virtualenvs.
Basically I have two different virtualenvs, in one of them elpy-goto-definition works as expected. If I change to the other environment using pyvenv-workon without leaving the buffer, then I got "No definition found". The problem is, both virtual envs seem to have all the required packages correctly installed.
Here is the elpy-config of the working environment:
Emacs.............: 26.1
Elpy..............: 1.34.0
Virtualenv........: AVF-ENV (/home/paulo/environments/AVF-ENV)
Interactive Python: ipython3 7.14.0 (/home/paulo/environments/AVF-ENV/bin/ipython3)
RPC virtualenv....: AVF-ENV (/home/paulo/environments/AVF-ENV)
 Python...........: python3 3.7.3 (/home/paulo/environments/AVF-ENV/bin/python3)
 Jedi.............: 0.18.0
 Rope.............: 0.17.0
 Autopep8.........: 1.5.4
 Yapf.............: 0.30.0
 Black............: 20.8b1
Syntax checker....: flake8 (/home/paulo/environments/AVF-ENV/bin/flake8)

And here is the config of the environment that is not working:
Emacs.............: 26.1
Elpy..............: 1.34.0
Virtualenv........: O2Sat (/home/paulo/environments/O2Sat)
Interactive Python: ipython3 7.19.0 (/home/paulo/environments/O2Sat/bin/ipython3)
RPC virtualenv....: O2Sat (/home/paulo/environments/O2Sat)
 Python...........: python3 3.7.3 (/home/paulo/environments/O2Sat/bin/python3)
 Jedi.............: 0.18.0
 Rope.............: 0.18.0
 Autopep8.........: 1.5.4
 Yapf.............: 0.30.0
 Black............: 20.8b1
Syntax checker....: flake8 (/home/paulo/environments/O2Sat/bin/flake8)

The only relevant difference I can see is the different version for Rope, which I fixed without any improvement.
elpy-doc is also not working in one of the envs, but is on the other.
I would appreciate any suggestion of what may be causing this behavior.
Thank you,


texts:
In vim, right after opening a file, I can type g; to go to
the place last edited.  This doesn't work in evil-mode with my
configuration.  Is there something I can do to make it work?


texts:
Very impressed with what I have seen in Org Mode so far. And who knows, may be, I will switch over to Emacs from vim. :)

Here is what is part of my .emacs:

(setq org-default-notes-file (concat org-directory "/notes.org"))

(setq org-capture-templates
      '(("t" "Todo" entry (file+headline "~/Documents/organize/org-mode/todo.org" "Tasks")
         "* TODO %?\n %i\n %a")))

(setq org-agenda-files '("~/Documents/organize/org-mode/"))

There is a directory ~/Documents/organize/org-mode. It has todo.org and notes.org files.

Yet when I start emacs, it produces an error: Symbol's value as variable is void: org-directory and when I try C-c c (tied to org-capture), it produces a window asking me to select a capture template. Options are: Task, Customize and Abort. Customize leads to a complicated dialog. And Task leads to an error: Target buffer .notes for file+headline not in Org mode.

I am new to Emacs and did not even remotely get what is happening here.

What do I need to do to go beyond this?


texts: Make isearch commands search only at the beginning of words

texts: How to make C-s (isearch-forward) and C-r (isearch-backward) search only for words that start with the argument passed to them, instead of searching for the argument even if it's in the middle of a word?


texts: Do I still need to create a .emacs file?

texts:
I have both aquamacs and emacs (installed from brew) on my macbookpro. I intend to learn to use aquamacs as my main editor/IDE.

When I use C-h v user-init-file in aquamacs, it reports the value as ~/.emacs.

However when I do a ls -a I cannot find any  ~/.emacs in $HOME. Instead I can see there is a .emacs.d directory.

I want to understand how does it work. Does emacs and/or aquamacs requires the presence of ~/.emacs strictly? Can I just drop some .el files in ~/.emacs.d and expect emacs/aquamacs to pick them up automatically?

My goal is to enable projectile in aqauamcs. I have already downloaded it from MELPA via cask  in .cask/24.4.1, but I am at loss about how to enable projectile in aqacmacs.


texts: gnus: fetch mails over IMAP from Outlook mail server

texts:
I'm trying to enable gnus to work with Outlook server (https://outlook.office.com/owa). At first I tried to re-use my old configuration for gmail (which worked fine for several years), but it didn't work in Outlook case.
Then I googled a lot, and it seems that the only way to make it work is to have davmail mail gateway on your workstation, and configure gnus to connect to davmail over IMAP.
Before I start digging in davmail more deeply, I'd like to clarify:

Is davmail really necessary?
I only need a single mail client to connect via DavMail to Outlook. Am I right that I only need workstation configuration?
If it is only workstation configuration, does it mean DavMail will only run as a GUI application? Can I not run it via service as a background process?

Below is my gnus configuration from gmail account which I tried to adopt for Outlook:
;;
(setq user-full-name "My Name")
(setq user-mail-address "my.email@outlook")

(setq smtpmail-auth-credentials "~/.authinfo")

(setq gnus-select-method
      '(nnimap "my_mail"
          (nnimap-address "outlook.office365.com")
          (nnimap-server-port 993)
          (nnimap-stream ssl)
          (nnimap-search-engine imap)
          (nnimap-authinfo-file "~/.authinfo")))

(setq smtpmail-stream-type 'ssl
       smtpmail-smtp-server "smtp.office365.com"
       smtpmail-smtp-service 587)

My ~/.authinfo :
machine outlook.office365.com login my.email@outlook password my_password port 993

Now when I start gnus it prints this in minibuffer:
Opening connection to outlook.office365.com via tls...
nnimap (my_mail) open error: ‘NO LOGIN failed.’.  Continue? (y or n)


texts: How to fix this startup package initialization problem?

texts:
All of a sudden Emacs returns an error at the startup, when I run $ emacs --debug-init from the terminal (linux) I get this debug error message:

Debugger entered--Lisp error: (wrong-type-argument listp <!DOCTYPE)
  package--read-archive-file("archives/gnu/archive-contents")
  package-read-archive-contents("gnu")
  package-read-all-archive-contents()
  package-initialize()
  eval-buffer(#<buffer  *load*> nil "/home/ffs/.emacs.d/init.el" nil t)  ; Reading at buffer position 136
  load-with-code-conversion("/home/ffs/.emacs.d/init.el" "/home/ffs/.emacs.d/init.el" t t)
  load("/home/ffs/.emacs.d/init" t t)
  #[0 "\205\266 \306=\203\307\310Q\202? \311=\204\307\312Q\202?\313\307\314\315#\203*\316\202?\313\307\314\317#\203>\320\321\322!D\nB\323\202?\316\324\325\324\211#\210\324=\203e\326\327\330\307\331Q!\"\325\324\211#\210\324=\203d\210\203\247\332!\333\232\203\247\334!\211\335P\336!\203\201\211\202\214\336!\203\213\202\214\314\262\203\245\337\"\203\243\340\341#\210\342\343!\210\266\f?\205\264\314\325\344\324\211#)\262\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" initialization format-message "`_emacs' init file is deprecated, please use `.emacs'" "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7]()
  command-line()
  normal-top-level()

What I suspect is the first lines of my init.el which has the following start:

(require 'package)
(package-initialize)
(require some_pakagename)
...

when I evaluate the line of (package-initialize) C-x C-e from inside the init.el file I get this error:

package-read-archive-contents: Wrong type argument: listp, <!DOCTYPE

I get the same error when I try doing M-x list-packages from the mini-buffer.

So, please could you help me spot the source of error?


texts: How can I use Gnus to access Gmail IMAP through http(s) firefwall?

texts:
My company's firewall only allow http and https connections.

To access internet, I have to specify the proxy before connecting the internet:

export http_proxy=http://my-company.com
export https_proxy=http://my-company.com

That's the current situation.

My question is how can I use Gnus to access Gmail's IMAP server through? What's the setup? Has anyone actually done this?

I've no problem to connect Gmail's IMAP server without proxy.

I did some investigation,
looks Gnus is using openssl to connect to the Gnus.

so the first step is ask openssl to use proxy (because Gnus is using openssl)
but I've not succeeded yet.


texts: shift selection not working for rebound M-{ backward-paragraph

texts:
I slightly simplified the keys for backward-paragraph and forward-paragraph:

(global-unset-key (kbd "M-{"))  ;; originally backward-paragraph
(global-unset-key (kbd "M-}"))  ;; originally forward-paragraph
(global-set-key (kbd "M-[") 'backward-paragraph)
(global-set-key (kbd "M-]") 'forward-paragraph)

These work, but I was hoping to get Shift Selection for free. In particular, the official manual says:

  If you hold down the shift key while typing a cursor motion command,
  this sets the mark before moving point, so that the region extends
  from the original position of point to its new position. This feature
  is referred to as shift-selection. It is similar to the way text is
  selected in other editors.

  ...

  Shift-selection only works if the shifted cursor motion key is not
  already bound to a separate command (see Customization). For example,
  if you bind S-C-f to another command, typing S-C-f runs that command
  instead of performing a shift-selected version of C-f (forward-char).

I have shift-select-mode as its default value, which is t.

However, if I now press M-{, I just get M-{ is undefined in the echo area, instead of shift-selected backward-paragraph as I was hoping. This seems to contradict the passage from the manual above. Is this a bug or am I doing something wrong?

edit: I also tried the following, taken from a similar question:

(global-set-key (kbd "M-[")
        (lambda ()
          (interactive "^")
          (backward-paragraph)))

And this had the exact same result as my initial method; e.g. M-[ effectively acts as backward-paragraph, but M-{ just says undefined


texts: org-mode: have flycheck resolve relative config while editing code blocks

texts:
Desired behaviour

While editing code blocks with org-mode by pressing C-c ' I'd like Flycheck to resolve relevant configuration
the same way it does for normal files. I'm using JavaScript, and these are .jshintrc files within the same ancestry.

To be more specific, I'd like the .jshintrc settings to be picked up while editing code if I had my project arranged like this:

~/project/file.org
~/project/.jshintrc

This doesn't work, but is my ideal behavior.

Lame solution

The following setup works:

~/project/file.org
~/.jshintrc

But it's not desirable because it sets defaults across all my projects.

Possible solutions

I'm not sure if the following solutions are good ideas, and I'm unsure how implement them:

Set buffer-file-name of local buffer when editing source code blocks in org-mode.
Add another function to flycheck-locate-config-file-functions.

Rationale

Looking at the Flycheck source, my "lame solution" works because Flycheck looks at the home directory in case other attempts to look up the configuration fail. This behavior is defined by flycheck-locate-config-file-functions.

flycheck-locate-config-file-ancestor-directories looks like the function I'd like to succeed in finding the configuration file. It looks like this:

(defun flycheck-locate-config-file-ancestor-directories (filename _checker)
  "Locate a configuration FILENAME in ancestor directories.

If the current buffer has a file name, search FILENAME in the
directory of the current buffer and all ancestors thereof (see
`locate-dominating-file').  If the file is found, return its
absolute path.  Otherwise return nil.

_CHECKER is ignored."
  (-when-let* ((basefile (buffer-file-name))
               (directory (locate-dominating-file basefile filename)))
    (expand-file-name filename directory)))

So, if buffer-file-name is set to an appropriate value we should be good. So what is its value for my code buffer? nil. OK, so what are the effects of setting this variable locally for Org code buffers (and how do I do this whenever I enter from org-mode with C-c ')?

Also, if I add my own look-up function to flycheck-locate-config-file-functions, that may solve the problem. But how would I resolve the directory of the current .org file from the buffer that lets me edit the JavaScript source?

A simpler solution is welcome as well.


texts:
I haven't used emacs before, but would like to learn how to use it properly for Python development.

From the past IDEs I have used I enjoyed the feature to obtain information on possible objects when I press C-SPC.
Also after each dot I would like to get a list of possible methods and functions.

Right now I am using a default auto-complete package but it only gives me the list after the first character after the dot which is a little impractical.

I've found jedi and installed it and added

;;Autocomplete
(add-hook 'python-mode-hook 'jedi:setup)
(setq jedi:complete-on-dot t)                 ; optional

in my .emacs. (Maybe someone can explain me why t is used after the complete-on-dot.)

But nothing relevant is happening. How should I solve that issue?

EDIT:
Got that warning:

Symbol's function definition is void: jedi:complete-on-dot

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the ‘--debug-init’ option to view a complete error backtrace.


texts: How to enable auto-revert-mode for files under a certain directory

texts:
I have my org files kept synchronized via rsync with various devices. These buffers are usually open in any running emacs instances due to agenda and capture. I want emacs to re-read these files from disk when something arrives via rsync. I know that auto-revert-mode handles this, but I want to enable it solely for files under my org directory.

How can I do this?


texts: org-mode and babel export - setting tangled (exported) files as readonly

texts:
I want to maintain a single org file which contained a plethora of different init files (.bashrc, .profile, .tmux etc that type of thing). Here's a portion:-
#+PROPERTY: header-args :tangle yes :comments no

* bashrc
  :PROPERTIES:
  :header-args+: :tangle "./DotFiles/.bashrc"
  :END:
** bashrc 1
   #+begin_src shell
     # -*- mode: read-only -*-
     # ~/.bashrc: executed by bash(1) for non-login shells.
     # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
     # for examples

Now when I tangle (C-c C-v t), the bashrc is correctly tangled and written to ./DotFiles/.bashrc. Notice the first line inside the #+begin_src :-
 # -*- mode: read-only -*-

Now, this works in that when I open that .bashrc in emacs then it's readonly, a subtle reminder that I need to edit the master org-file.
Currently I need to add that to each and every dotfile section I have in my master org file. Is there a way to specify a global "first line" in each exported file? I would have thought a
header-args: :comments "# -*- mode: read-only -*-"

would do that but alas not. Is there  cleaner way to do this than the way I'm currently doing it?


texts: How can i use a different shell in Emacs Shell?

texts:
I am currently using Zsh in my regular terminal app on my Mac OS X. However, it's heavily customized and colors don't appear properly inside Emacs. So I am thinking, I should probably use shell-mode with a different zshrc or use "Bash" as the default shell in shell-mode.

Is this possible?

Thanks in advance.


texts: Tangle Org file containing #+INCLUDE directives and multiple tangle targets

texts:
Context
I'm using org-babel-tangle to generate my configuration from an Org file config.org. Recently, I did some clean-up by

dispatching config.org to multiple Org files config/*.org;
replace the content of config.org with multiple #+INCLUDE: config/*.org directives.

To illustrate a bit, the directory tree is as follows:
config/
|______ A.org
|______ B.org
|______ C.org
|
config.org

where
## config.org
#+INCLUDE: config/A.org
#+INCLUDE: config/B.org
#+INCLUDE: config/C.org
...

and
## [ABC].org
#+BEGIN_SRC emacs-lisp :tangle target1.el
;; elisp code
#+END_SRC

#+BEGIN_SRC emacs-lisp :tangle target2.el
;; elisp code
#+END_SRC
...

Issue & attempt
However, I ran into the issue that org-babel-tangle doesn't handle #+INCLUDE directives. So, I follow the idea of this post which consists of

exporting config.org to an Org file config-export.org with org-export-to-file;
org-babel-tangle the exported Org file config-export.org to tangle targets.

This approach does replace the multiple #+INCLUDE directives of config.org by the content of config/*.org, but all tangle options are erased. Namely, the exported config-export.org looks like this (all emacs-lisp tangle target filename are lost):
## config-export.org
#+BEGIN_SRC emacs-lisp
;; elisp code for target1.el
#+END_SRC

#+BEGIN_SRC emacs-lisp
;; elisp code for target2.el
#+END_SRC
...

Question
How to org-babel-tangle an Org file with #+INCLUDE directives as it is intended?
(i.e. (1) include all Org files (preserving :tangle target.el), then (2) org-babel-tangle the whole Org file.)
Related question
A similar question has been raised in the Org mode mailing-list.


texts:
Something setqs desktop-dirname to nil after my "init.el" is loaded.
I want to track down the offending code.

Just before the end of "init.el", desktop-dirname is correctly set.

I checked run-hooks by giving advise to it, but the variable was found to be set outside of run-hooks. But there are more hook-runners, timers, etc...

Is there a general technique to pin-point the code that writes to a variable?


texts: Pass keymap as an argument to a function

texts:
I have the hard time straggling of passing elisp keymap to a custom function. I expect that after major mode has loaded (in my case it's clojure-mode) my new keybindings become available, but they don't:
;;; Settings.
(straight-use-package 'paredit)

(defun my/shared-lisp-mode-hook ()
  (require 'paredit)
  (my/vim-paredit-init clojure-mode-map))

;;; Clojure.
(straight-use-package 'cider)

;; This doesn't work.
(defun my/vim-paredit-init (map)
  (evil-define-key 'normal map (kbd "<localleader>r") #'paredit-raise-sexp))

;; This works, but not what I want.
;; (defun my/vim-paredit-init (map)
;;   (evil-define-key 'normal clojure-mode-map (kbd "<localleader>r") #'paredit-raise-sexp))

(defun my/clojure-mode-hook ()
  (my/shared-lisp-mode-hook))

(add-hook 'clojure-mode-hook #'my/clojure-mode-hook)

I know I miss something conceptual and trivial, but couldn't come up to any, but duplicating paredit key bindings for all major modes: elisp, clojure, which I want to avoid...


texts: Insert another XML element of the same type

texts: In nxml-mode, I would like to insert an XML tag that has the same name as the nearest closing tag before point, without having to retype (or complete) the same tag name each time I do it.


texts: How to efficiently debug emacs package conflicts (strategies too)

texts:
I currently have an emacs package conflict occuring. It is a difficult one to pinpoint as it happens occasionally.

I have started using M-x unload-feature to unload packages from memory, get out of the error state and identify the package causing the conflict error.

This is a good start but I have noticed that not all my packages are loaded in memory. As I have 161 packages installed, including dependencies. I do not want to manually go through each one, then run unload feature, only to find out it that package is not loaded.

To start, is there a way to display all packages that are currently loaded?

I was thinking of displaying all major and minor modes as a start. But I cannot even work out how to do that!

Any suggestions?


texts:
I want code completion for C/C++ functions and variables from headers. I tried to install Auto-complete and Company, but C/C ++ functions/variables aren't complemented.

Here is the relevant portion of my .emacs file:

;; Auto-complete (AC)
(require 'auto-complete)

(require 'auto-complete-config)
(ac-config-default)


texts:
I am starting the emacs server using

systemctl --now --user enable emacs

That server is running, if I run

systemctl --user status emacs

I got

$ systemctl --user status emacs
● emacs.service - Emacs text editor
   Loaded: loaded (/usr/local/lib/systemd/user/emacs.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2018-06-09 09:27:56 CDT; 2 days ago
     Docs: info:emacs
           man:emacs(1)
           https://gnu.org/software/emacs/
 Main PID: 17613 (emacs)
   CGroup: /user.slice/user-1000.slice/user@1000.service/emacs.service
           └─17613 /usr/local/bin/emacs --fg-daemon

But, when I try to connect using emacsclient -c some_file.py

I got

$ emacsclient -t .psqlrc
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".

What am I missing?

EDIT:

Following the advice of @Tobias I ran

$ sudo netstat -xauopen | grep emacs

And the result was the following:

unix  3      [ ]         STREAM     CONNECTED     61841    17982/emacs
unix  3      [ ]         STREAM     CONNECTED     62269    17982/emacs
unix  3      [ ]         STREAM     CONNECTED     62268    17982/emacs

I was expecting see more information, but this doesn't seem right. What is happening?


texts:
As an elisp beginner I'm trying to grasp what the "best practice" data structure is. For example, I did the simple adding (C-x a, i, g) of things to my abbrev_defs and when I look I see this:

...

(define-abbrev-table 'global-abbrev-table
  '(
    ("crwdesc" ":PROPERTIES:
:SEMANTIC:
:DESC:
:END:" nil 10)
    ("propid" ":PROPERTIES:
:CUSTOM_ID:
:SEMANTIC:
:DESC:
:END: " nil 0)
   ))

I also see org-element taking a "lisp representation" and turning it into org-mode output:

#+BEGIN_SRC emacs-lisp :results raw
(org-element-interpret-data
 '(headline (:title "One headline" :level 1)
            (property-drawer nil ((node-property (:key "property1" :value "value1"))
                                  (node-property (:key "property2" :value "value2"))))
            (#("Some much longer content."))))
#+END_SRC

#+RESULTS:
* One headline
:PROPERTIES:
:property1: (org-clock-in (quote (16)))
:property2: value2
:END:
Some much longer content.

Also, the org-element-parse-buffer seems to produce a very elaborate AST which, again, is nested lists. Is this the main data structure when working with elisp? It would seem so -- almost duh! so since this is a lisp. But are there other data structures that are also used? I ask because other data storage and config files (XML, RDF, etc.) generally don't use nested lists. For example, does elisp ever favor the more typical config text layout of simple lines? Or is the mantra "keep it lists?" And I might as well ask about alists while I'm at it. When are they desirable?

I ask all this because your typical tutorial might show you how to use alists, but they rarely talk about its real-world application, when to use it, when not to, or its importance to the language's eco-system.


texts: CSS classes autocomplete not working with web-mode

texts:
I'm struggling with a problem with Spacemacs and I don't know what I'm doing wrong (maybe a lot of things).

I have created a TAG file for my project. The tags seem to work well because I can navigate to the definition or find the tag with find-tag.

The problem is CSS autocomplete popup it's not showing. So when I'm editing an HTML file, I have not autocompletion for CSS classes. I can use helm complete at point, though.

For clarification, I want a popup similar to this:

I have tried to follow the advice on this blog post but without results.

Any help will be appreciated.

EDIT:

I was making some tests, and I have been able to prove that the problem is that company-gtags is not enabled within a string (a class element for example). Instead I have tried company-etags and if I start the backend manually with company-beging-backend, I can see the pop up with the CSS classes. As far I can see in this github PR company-etags has an option to enable code completion on strings. But I don't know how to add it to my .spacemas. I have tried into user-config and user-init but still not working.


texts: What mix of customisations are required to have org files always open exactly as they were closed?

texts: org-customize has a node for startup folded, with options no fold, fold, content, and show everything. There doesn't seem to be an option for "remember last folded state". For such a customisable major mode, I think this is a glaring omission. I was even pointed toward the undocumented var org-inhibit-startup-visibility-stuff, but this just gives the completely open mode.


texts: How to restart elpy if it is not launch?

texts:
I am working with python using Emacs 26.3. My goal is to jump to definition of the function and jump back, for that I am using https://github.com/jacktasia/dumb-jump, which runs elpy-goto-definition on the background.
I am starting emacs on startup using crontab using (&>/dev/null emacsclient -t -q &). On that case, elpy-goto-definition never works. I have to restart emacs. But after the restart, it takes around 30 seconds for elpy to launch, sometimes it does not launch (I do not know why).

What may be the main reason that let elpy-goto-definition to fail. Can I force elpy-goto-definition to work if it fails? or restart elpy within emacs if possible?

My setup:
(setq elpy-rpc-backend "jedi")
(add-hook 'elpy-mode-hook (lambda () (highlight-indentation-mode -1)))
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate)

;; https://emacs.stackexchange.com/a/19194/18414
(defun goto-def-or-rgrep ()
  "Go to definition of thing at point or do an rgrep in project if that fails"
  (interactive)
  (condition-case nil (elpy-goto-definition)
    (error (elpy-rgrep-symbol (thing-at-point 'symbol)))))

(global-set-key "\C-x\C-j" 'goto-def-or-rgrep)


texts:
I have some code using (looking-back … (line-beginning-position)).  Doc string of looking-back states that it's better to avoid this function because of slowness. I'm curious will following approach be faster?

(save-excursion
  (goto-char (line-beginning-position))
  (looking-at regexp stuff))


texts: How to restrict find-tag-regexp to search only the symbol part of TAGS

texts:
A typical line in a TAGS file looks like this (note use of special characters ^? and ^A)

(defvar copyright-owner user-full-name^?copyright-owner^A213,7296

and a find-tag-regexp will search the entire line. But I want to restrict my searches to just the 2nd column, i.e. copyright-owner. In particular, for this example I want to avoid false positives for searches of user-full-name from finding this entry.

How can I restrict find-tag-regexp to just the matching part of the line and not the whole line?

Format defined in more detail here https://en.wikipedia.org/wiki/Ctags#Etags_2


texts:
I have been struggling with the following issue on Windows for the last couple of years. For some reason, certain symbols are not displayed properly:

Everything displayed is those ? symbols.

If I place the cursor over any of those ? symbols, describe-font gives the following:

name (opened by): -outline-Fira Code-normal-normal-normal-mono-13-*-*-*-c-*-iso8859-1
       full name: Fira Code-10.0
            size: 13
          height: 15
 baseline-offset:  0
relative-compose:  0
  default-ascent: 12
          ascent: 12
         descent:  3
   average-width:  8
     space-width:  8
       max-width: 39

The following is the relevant code I use to setup fonts and symbols:

(defun font-exists-p (font)
  "Comprueba si una tipografía existe. Sacado de https://redd.it/1xe7vr"
  (if (member font (font-family-list))
      t
    nil))

(add-to-list 'default-frame-alist '(font . "Fira Code-11"))
(add-to-list 'initial-frame-alist '(font . "Fira Code-11"))

;; Para NS/Cocoa
(when (eq system-type 'darwin)
  (set-fontset-font t 'unicode (font-spec :family "Apple Color Emoji") nil 'prepend))
;; Para todos los demas sistemas operativos
(when (not (eq system-type 'darwin)))
  (set-fontset-font t 'unicode (font-spec :size 20 :name "Symbola") nil 'prepend))

I have double-checked and installed all fonts from the all-the-icons project and also Symbola, but it seems that Fira Code overrides other fonts, which are not set.

This issue does not occur on GNU/Linux or MacOS.

EDIT:

This is what describe-font output on GNU/Linux where all symbols are displayed correctly:

name (opened by): -CTDB-Fira Code-normal-normal-normal-*-15-*-*-*-m-0-iso10646-1
       full name: Fira Code:pixelsize=15:foundry=CTDB:weight=normal:slant=normal:width=normal:spacing=100:scalable=true
       file name: /home/jorge/.fonts/FiraCode-Medium.ttf
            size: 15
          height: 19
 baseline-offset:  0
relative-compose:  0
  default-ascent:  0
          ascent: 15
         descent:  4
   average-width: 10
     space-width: 10
       max-width: 10

On GNU/Linux -iso10646- is used instead of -iso8859-. This is the setup for character encoding on Emacs:

(prefer-coding-system       'utf-8)
(set-default-coding-systems 'utf-8)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(setq default-buffer-file-coding-system 'utf-8)
(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))

EDIT 2:

I'm using GNU Emacs 25.3.1 (x86_64-w64-mingw32) of 2017-09-17 installed via Emacs Powerpack ( https://gitlab.com/vancan1ty/emacs_powerpack )


texts: How do I turn off the automatic list feature in org-mode?

texts:
I want to write a list like

1. bla
2. blabla
2.1 blabla

But having written 1., org-mode tries to infer what I want on the next line, which makes the numbering impossible to edit. How do I turn off this feature?


texts:
I have a function which returns a file path, but the returned value has backslash excaped 'special' characters e.g.

"/home/fred/Documents/This\ file\ \(20200120\).txt"

but the function where I want to use this value does not handle the string escaping and just wants the plain filename string i.e.

"/home/fred/Documents/This file (20200120).txt"

What would be the canonical way to do this in elisp?

My quick and dirty solution (which seems to work) is a simple function

(defun tx-parse-path (p)
  (concat (reduce #'(lambda (acc l)
                      (if (not (= ?\\ l))
                          (cons l acc)
                        acc))
                  (reverse p)
                  :initial-value '())))

I suspect there is some built-in function, but have not found it. I don't need to worry about win32 compatibility (only use GNU Linux and macOS) and of course, the flaw with the brute force solution above is that it will strip legitimate '\' from a filename.


texts: Please help understanding following elisp code of origami package

texts:
In file origami.el of package origami from MELPA is the function origami-fold-node and there is the following piece of code, which I do not understand:

(when (-some? (lambda (pair)
                  (let ((a (car pair))
                        (b (cadr pair)))
                      (when b ;for the odd numbered case - there may be a single item
                          ;; the < function doesn't support varargs
                          (or (>= (origami-fold-beg a) (origami-fold-end a))     ;; *1* clear
                              (>= (origami-fold-end a) (origami-fold-beg b))     ;; *2* ??
                              (>= (origami-fold-beg b) (origami-fold-end b)))))) ;; *3* clear
              (-partition-all-in-steps 2 1 sorted-children))
    (error "Tried to construct a node where the children overlap or are not distinct regions: %s"
           sorted-children))

In this piece of code happens a sort of range check (I think) and there are 3 points of failure, see comments with *<N>* at the end of those lines.

Case *1* and *3*are clear begin must be before end.

But case *2* I do not understand, why is this a failure?
If beg a is even bigger than end b everything is fine, because a wraps b. And then of course end a must be bigger than beg b.

Could someone please enlighten me?


texts: How to fix markdown-mode's fill-paragraph?

texts:
markdown-mode is
pretty good at filling paragraphs overall, but there's one flaw that
really bothers me. If a paragraph contains a line which ends in two
spaces, it only starts filling never fills that line.

For instance, take the following example, where the second line ends in two spaces.

If I hit M-q right here at the start, this line will get broken into two, but the others won't.
If I hit M-q right here only the NEXT line will get split. All because this line here ends in two spaces.__
If I hit M-q right here, this line will get broken into two, but the others won't.

The example explains itself. Even If I hit M-q at the start of each line, I'm still left with this:

If I hit M-q right here at the start this line will get broken into
two, but the others won't.
If I hit M-q right here only the NEXT line will get split. All because this line here ends in two spaces.__
If I hit M-q right here, this line will get broken into two, but the
others won't.

What I would like to have is this:

If I hit M-q right here at the start this line will get broken into
two, but the others won't. If I hit M-q right here only the NEXT line
will get split. All because this line here ends in two spaces.__
If I hit M-q right here, this line will get broken into two, but the
others won't.

Q: How can I get fill-paragraph to behave like this?

Clearly, markdown-mode is considering the entire middle line to be a
paragraph separator, when it should be just the spaces at the end.


texts: format java source code natively based on CodeFormatterProfile

texts:
Is there an emacs tool to format java code according to a Java Code Formatter Profile (xml) spec, such as the one below?

https://github.com/google/styleguide/blob/gh-pages/eclipse-java-google-style.xml

I'm aware I could use an after-save-hook in java mode to invoke an external tool, like eclipse, to achieve this, but I'd like to know if there is a native emacs tool.


texts:
I have a buffer with a lot of instances of words surrounded by '<' and '>', and I want to replace them all with the just capitalized word. E.g. <foo> -> FOO.

I read the regex chapter of the gnu emacs manual, but I'm still lost.


texts: Trying to connect to a MySQL database using SQLi with no luck

texts:
Been trying to follow this guide to setting up SQLi

http://truongtx.me/2014/08/23/setup-emacs-as-an-sql-database-client/

I use Customize Group SQL to set the parameters (host, username, etc.,) and that seems to go fine. I choose the MySQL product, also fine. Then I attempt to start the SQLi session and I get a new buffer with SQL as the name and SQLi[MySQL]:no process in the modeline.

The buffer says: 'emacs': I need something more specific.

Am I doing something wrong?


texts: Multiple major modes in one buffer (e.g., python-mode & LaTeX-mode)

texts:
Using the LaTeX-package pythontex I one can insert python code into the latex document which is executed (and printed to your latex file if you want) if you run latex. I use auctex for editing latex files, however editing the python code inside the latex document is a bit painful since the buffer is in latex mode and not in python mode, so there is no help for proper indentation of the python code and no syntax highlighting.

So is there any reasonable way to mix the python mode with the latex mode? For example that the buffer automatically jumps to python mode if the point is inside  a python code snipped? What do I have to add to my .emacs file to make it work? Any other ideas?

\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\usepackage{pythontex}

\begin{document}

\begin{pycode}
print('test1')
def f( ):
    print('test2')

f()
\end{pycode}

\pyc{f()}
\end{document}

Note that pythontex has multiple environments and commands which can contain pythoncode, for example pycode or pyverbatim as environments or \pyc or \py as commands.


texts: I'm trying to use flyspell from inside the terminal but when I run flyspell-correct-word-before-point I get the error This command requires pop-up dialogs. Is there a way to work around this issue? Am I just misconfigured? I don't believe I have any flyspell-specific configuration settings.


texts:
How do I declare custom completions for command arguments to AUCTeX?

I have a LaTeX package that defines a number of macros. I'm writing the Elisp style support manually as some of the TeX code is rather hairy. One of the macros is \ref-like, so in the style support file, I have

(TeX-add-symbols '("myref" TeX-arg-ref))

If I insert \ref or \myref with TeX-insert-macro, I get prompted for a label with completion. If I type \ref{ and press M-TAB (TeX-complete-symbol), I get completions of labels. But if I type \myref{ and press M-TAB, I only get the fallback to dictionary words.

How do I tell AUCTeX that the first argument of \myref should be completed as a label?


texts: When I open the commit view for a regular commit in magit, I can see the diff for each file. When I open a merge commit, I can only see a summary of the number of lines that were changed. Is there a way to get the first behavior for merge commits?


texts: whitespace-mode does not display hidden characters in a patch file

texts:
I have a patch file on which if I do cat -A , I get :
  if (zif->rtadv.AdvIntervalOption)$
    {$
      struct nd_opt_adv_interval *ndopt_adv = $
^I(struct nd_opt_adv_interval *)(buf + len);$

But on emacs with whitespace-mode enabled I do not see any of the hidden characters:

Why?
I do not know what controls this behavior, and whitespace mode works fine in fundamental & c buffers.
Here is my whitespace display mappings:
'((space-mark 32
              [183]
              [46])
  (space-mark 160
              [164]
              [95])
  (newline-mark 10
                [36 10])
  (tab-mark 9
            [187 9]
            [92 9]))


texts: How to display org-pomodoro timer in mode-line

texts:
I see a video on youtube which display pomodoro clock  in mode line

I installed lolownia/org-pomodoro: pomodoro technique for org-mode but it's clock does not show on the mode line

Alternatively, tried the answer How to show org-clock (and org-pomodoro) timer in mode-line? - Emacs Stack Exchange

Unfortunatley, it's wrong to report error when start emacs.

I found the the rainbow is nyan-mode: Nyan Cat for Emacs!  which just display the scroll of the buffer.

How could I show a basic orgclock in mode line?


texts: How to Customize Rainbow-Delimiter and Emacs-Color for a theme with Dark Background

texts:
I have installed rainbow-delimiter packages, and I tried to customize it based
on the code written in this page.
However, I found out that some generated colors are too dark when it is used
with a theme with a dark background such as Zenburn.

My question is how to customize it so that the generated color can be more brighter.


texts: How to force evaluation of a statement in my `init` file?

texts:
TL;DR: How can I force evaluation of a setq statement at start-up so that imenu updates appropriately?  (You can skip down to the second code-block below, if you want.)

I love the concept of imenu (esp. when integrated with helm) and I think it has great potential to improve my workflow...assuming I learn how to correctly set definitions for imenu categories.

As a simplified example, let's say that I'd like to add a few definitions to my init file's imenu which would be useful when making updates - namely, the list of imported packages.

Let's consider the following three lines as the code we want to parse (purely illustrative; my init file doesn't actually have an explicit line for importing dired and electric):

(defconst dc/default-directory "/path/to/directory")
(use-package dired)
(use-package electric)

In order to extract the constants and package names in imenu, I've included the code below in my init.el file.  This code works BUT only after I manually eval the second line, (i.e., the second setq statement below).

(setq dc-additions '(("Imported packages" ".*(use-package \\(.*\\))*" 1)
                     ("Defined constants" ".*(defconst \\(.*\\))*"    1)))
(setq imenu-generic-expression (copy-sequence `(,@dc-additions ,@imenu-generic-expression)))
(add-hook 'emacs-lisp-mode 'imenu-generic-expression)

If I don't manually evaluate the second step, the imenu list shows only the default definitions.  However, after I eval the second statement above, the imenu list correctly include includes items based on my definition.

How can I force evaluation of the second statement?  In other words, what can I do to to ensure that imenu will automatically consider items based on my definition?

Exhibit 1: imenu after start-up but before I manually eval the second setq statement:

Exhibit 2: imenu after I manually eval the statement:


texts: How to jump to matching (double or single) quote of a quoted string?

texts: When cursor on one quote symbol, how to jump to the pairing quote?


texts: Retaining focus while displaying graphics windows

texts:
NB: The Emacs world uses the word frame to refer to what in most other contexts is called window, and uses the word window to describe something else.  In this post, however, the word window always refers to an X11 window.

I routinely run subordinate shells under Emacs.  In these shells I often need to run programs that pop up a separate graphics window and then proceed to display sequences of images (charts of scientific data) in this window.  After displaying each image in the sequence, the program prints a prompt such as

Hit <Return> to see next plot:

...and pauses for user input1.

Unfortunately, at this point the graphic window has the focus, and does not respond to any keyboard input.

Therefore, in order to see every next image, one must first switch the focus to the Emacs window before one can press Return.

This is no big deal when the sequence consists of 2-3 pictures, especially since I can switch the focus from the keyboard (with Alt+Tab but the utility of this sort of program is to be able to quickly inspect tens (sometimes even hundreds) of images.  It is in this use-case that the extra step of returning the focus to the Emacs window starts getting seriously in the way.

Is there a way to configure Emacs so that, whenever a subordinate program pops up a new window

the Emacs window retains the focus; and
the new window (even without the focus) remains always on top of the Emacs window2

?

(Of these two items, the first one is far more important than the second one.)

1A quick example of the problem, for those who have R installed, is the following: (1) start a sub-shell (M-x shell); (2) in this shell start an interactive R session; (3) in the R session run the command example(plot).  This will present a sequence of examples from the plot command's documentation page.  (If you have the ESS (aka Emacs Speaks Statistics) package installed, steps (1) and (2) can be replaced with the command M-x R.)  This example is a somewhat different use-case from the one I'm dealing with, since it's about displaying documentation rather than data, but it is one that others can more readily try out than my actual use-case, and conveys all the essential information.

2 When working with a small screen (e.g. a laptop) the focus-switching business entails the additional (though more tractable) inconvenience that the window with the focus, by default, obscures all other windows.  This means that, when the Emacs window is maximized (as is normally the case when I work on my laptop, for example), switching focus entails obscuring the plot temporarily.  This greatly hampers the ability to make visual comparisons between a plot and its successor.  As already said, this problem is at least solvable: un-maximize the Emacs window, and give it a size consistent with having both it and the graphic window simultaneously visible.


texts: How to detect the modifier key state with track-mouse?

texts:
When using track-mouse pressing modifier keys doesn't generate events.

Is there a way to detect if any modifier keys are held while tracking the mouse?


texts:
I am migrating my email workflow to gnus. I want to use splitting to keep things organized and for the splits to take effect on the server. I think my splits are working for incoming mail, but I want to sort my old mail too.

(setq gnus-select-method '(nnimap "outlook.office365.com"
                  (nnir-search-engine imap)
                  (nnimap-stream starttls)
                  (nnimap-split-download-body t)
                  (nnimap-split-predicate "UNDELETED")
                  (nnimap-split-fancy  (| ("MailScanner4-SpamCheck" "spam" "spam\.detected")
                               (from ".*@spammer.com" "mail\.custom\.spams")
                               (from ".*acm.org" "mail.acm")
                               "mail\.misc"))))


texts:
In eshell I can redirect the output of a command (foo) to a buffer (bar) by inputting:

foo > #<buffer bar>

I want to customize this syntax the following way:

foo > #bar

Is it possible to customize it? How?

Details
emacs version: GNU Emacs 24.3.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.22.10) of 2017-09-20 on c1bm.rdu2.centos.org


texts:
I am trying to start using Doom Emacs, but I find it increasingly difficult to find what the new keybindings are for certain tasks, like the ones for using Org Mode.
When I use vanilla Emacs, there is the documentation for every tasks, so how do people using other distributions, like Doom Emacs, find what all the new keybindings are?
For example Org Mode has hundreds of keybindings, are all these remapped to new ones for Doom? How do I find them?


texts:
I have the strong feeling that the functionality of the following two functions should already be provided by some standard macro or function in emacs. It would be nice if someone could give me a pointer to those.

(defun classify (classifier list &rest key-values)
  "Maps the LIST entries through CLASSIFIER to class denotators.
Returns the alist of equivalence classes.  Each equivalence class
is a cons whose `car' is the class denotator and the cdr is the
list of members.
Keywords supported: :test"
  (let ((test (or (plist-get key-values :test) 'equal)))
    (let (classify-res)
      (dolist (classify-li list)
    (let* ((classify-key (funcall classifier classify-li))
           (classify-class (cl-assoc classify-key classify-res :test test)))
      (if classify-class
          (setcdr classify-class (cons classify-li (cdr classify-class)))
        (setq classify-res (cons (list classify-key classify-li) classify-res)))))
      classify-res)))

(defun max-el (list &rest key-values)
  "Return maximal element.
Keywords supported: :test"
  (let ((max-el-max (car-safe list))
    (max-el-test (or (plist-get key-values :test) '>)))
    (setq list (cdr list))
    (while list
      (when (funcall max-el-test (car list) max-el-max)
    (setq max-el-max (car list)))
      (setq list (cdr list)))
    max-el-max))

Example:

(setq classes (classify 'file-name-extension
               '("first.txt" "second.txt"
                 "script1.el" "script2.el" "script3.el")))

gives

(("el" "script3.el" "script2.el" "script1.el") ("txt" "second.txt" "first.txt"))

and

(max-el classes :test  (lambda (c1 c2) (> (length c1) (length c2))))

gives

("el" "script3.el" "script2.el" "script1.el")

Note, that I did not care very much about the efficiency of the function definitions above since I assume that there is already an efficient standard version. These definitions are just listed here to show which behavior I need.


texts:
I'm using expand-region and experimenting with it trying to find the right key binding

As per expand-region README it binded to

(global-set-key (kbd "C-=") 'er/expand-region)

But I'm not satisfied, I thing it better keybind would be

(global-set-key (kbd "C-S-SPC") 'er/expand-region)
(global-set-key (kbd "C-SPC") 'er/contract-region)

Since we nomally use C-SPC to set-mark, which would be ovrrided by this config, but C-SPC when region selected will reset the region the reset to the current-cursor-position, so binding er/contract-region to C-SPC make sense so I did.

(defun my-contract-region()
    (interactive)
    (if (use-region-p)
        (er/contract-region)
        (set-mark-command)))

(global-set-key (kbd "C-SPC") 'my-contract-region)

but when using in I couldn't figure out the argument error

Edited 1:

Yes I turned on debugging but, still could'nt figure out why, :(


texts:
EDIT: Now I can see the error only happens if I include certain code to do an automatic push, adopted from https://gist.github.com/3111823. It seems that this block of code wants to use org-mobile-files-alist while it hasn't been initialized, because 'org is set to have an async loading by default. No matter whether I put the code in init or config when I require 'org, it doesn't seem to recognize the variable. Another person seems to be encountering the same error, using the auto-push code below, as seen on github.

Unfortunately if I put the code after (package-initialize) it doesn't seem to run at all(i.e. no automatic push no matter what).

The code to do automatic push:

  ;; https://gist.github.com/3111823 ASYNC org mobile push...
(require 'gnus-async)
;; Define a timer variable
(defvar org-mobile-push-timer nil
  "Timer that `org-mobile-push-timer' used to reschedule itself, or nil.")
;; Push to mobile when the idle timer runs out
(defun org-mobile-push-with-delay (secs)
  (when org-mobile-push-timer
    (cancel-timer org-mobile-push-timer))
  (setq org-mobile-push-timer
        (run-with-idle-timer
        (* 1 secs) nil 'org-mobile-push)))
;; After saving files, start an idle timer after which we are going to push
(add-hook 'after-save-hook
(lambda ()
  (if (or (eq major-mode 'org-mode) (eq major-mode 'org-agenda-mode))
    (dolist (file (org-mobile-files-alist))
      (if (string= (expand-file-name (car file)) (buffer-file-name))
          (org-mobile-push-with-delay 25)))
    )))

The code to initialize org mode asynchronously:

(require 'package)
(setq package-enable-at-startup nil)
(package-initialize)
(require 'org)
(require 'ox)
(require 'ox-beamer)
(require 'ox-latex)
(setq org-export-async-debug nil)

I'm new to Emacs and I'm actually using a starter kit called spacemacs. So I'm not sure how to fix this problem even after two hours' of trying...

I'm seeing the error Symbol's function definition is void: org-mobile-files-alist when performing certain operations. Strangely, the error doesn't occur again after I execute org-mobile-push or org-mobile-pull at least once. The nuisance is that it doesn't seem to only influence org mobile itself, but also interferes with other functionalities such as archiving. Now whenever I run C-c C-x C-a I'll get this error and the entry will not be removed from its original .org file, although it indeed does get archived into the .org_archive file. Thus if I try to archive multiple times, the entry gets repeated in the .org_archive file but it still remains in the original file. It seems that the process of removing the entry and then saving the file gets interrupted by this error.

An example:

Copied: Subtree(s) with 262 characters
Saving file /Users/JX/Dropbox/orgmode/Personal.org_archive...
Wrote /Users/JX/Dropbox/orgmode/Personal.org_archive
let: Symbol's function definition is void: org-mobile-files-alist

I already set my org-mobile-files variable. However it seems that for some reasons it doesn't get picked up until I execute org-mobile-push or org-mobile-pull manually.

org-mobile-directory "/Users/JX/Dropbox/MobileOrg"
org-mobile-files (quote (org-agenda-files))


texts: AUCTeX: how to compile a file, which does end in '.ins'

texts:
I am playing around with some LaTeX's DocStrip package.

(For those interested: it is a LaTeX package, to create documented code, in order to write e.g. a style file and incorporate the documentation in one file.  DocStrip will Strip the Documentation and generate a clean and fast loadable Stylefile but is also able, to create an exhaustive documentation on that style file.)

To use DocStrip you usually have two kind of files: the .dtx containing both documentation and the code and a second file, which is similar to a Makefile.  Usually it has the file extension .ins to be not mixed up with normal LaTeX files.

If you want to extract the style file (or any other package), you have to run LaTeX on your "Makefile", that is

 latex sample.ins

I want to be able, to use the normal C-c C-c key, to start this compilation.  But AUCTeX is adding the extra file extension .tex, so that the real call is

 pdflatex -file-line-error  --synctex=1 -interaction=nonstopmode "\input" sample.ins.tex''

Ho do I configure Emacs/AUCTeX to run

 pdflatex -file-line-error  --synctex=1 -interaction=nonstopmode "\input" sample.ins''

instead?

I already tried to define the master file to be "sample.ins", but even than .tex is added.


texts: TTY Emacs from within Windows 10 - garbage appears when switching windows

texts: Due to severe limitations at work I'm forced to run TTY Emacs on a remote Unix server via SSH (launched from Git Bash console under Windows 10... don't ask...). I got my dev environment mostly in order, but I've noticed one annoying quirk while switching windows (using M-Tab). Whenever my cursor is positioned inside an Elisp-enabled buffer, textual garbage gets added to that buffer around the region. When I switch from Emacs to another window [O ... ] wraps around region. When I switch back to Emacs [I ... ] appears (... stands for region). The garbage is ordinary text, so it's easy to get rid of it (especially with Paredit enabled), but it's getting on my nerves. Any idea what might be causing this and/or how to get rid of it?


texts: emacs: What is a subtree in org mode? and how do you create one

texts:
I searched Google for "emacs org subtree" but couldn't find
any introductory information on this particular aspect
of org mode.
My questions are

What is it?
How do I create one?
If possible, can I use it as a todo list?
Can I move up/down items using a single key?


texts: Defining a function that takes keyword arguments and a variable number of positional ones

texts:
I want to define a function that takes both keyword arguments (as in &key) and a variable number of positional ones (&rest). They should be independent of each other, the keyword list should not be part of the &rest variable:
(???-defun foo (&key key &rest rest)
  (list key rest))

(foo :key 'a 1 2)
=> '(a (1 2))

cl-defun accepts both keywords, but the behavior is not what I'm looking for. The closest I got is:
(cl-defun foo (&rest rest &key key &allow-other-keys)
  (list key rest))

(foo :key 'a 1 2)
=> (a (:key a 1 2))

Is there an idiomatic or built-in way to achieve what I'm looking for?


texts: How to use a particular syntax table with arbitrary functions?

texts:
I have an Elisp function which takes a string and performs capitalization (capitalize) on it, and then inserts it into a file. Apparently capitalize doesn't consider the single quote as a "word constituent" and therefore I get results like "I'M A Cat".
I understand that this is because of the syntax table in place. The default returned by (standard-syntax-table) treats the quote as a "word constituent", so I'm assuming that code execution uses emacs-lisp-mode-syntax-table which has it otherwise.
I tried executing capitalize inside with-temp-buffer but that didn't work for some reason.
So my questions are:

Does the functions I have in my config useemacs-lisp-mode-syntax-table when I call them?
What's the standard way of dealing with this? What's a way to isolate my functions from inheriting all this context? I don't want to manually create a new table and use with-syntax-table for every function in my config or change the current table using modify-syntax-entry, and I want my strings to be treated like normal English sentences.


texts: Any way to get a working separator line between fringe/line numbers and the buffer?

texts:
is there any way to get a separator like the one for the split buffers (line in the middle of the image) for the line numbers/fringe?

I tried (setq linenum-format "%4d \u2502 ") but that gives me a buggy weird broken lines with varying widths -.-


texts: When a heading is DONE, I don't see the link

texts:
I am using:

Spacemacs: 0.200.13
Org: 9.4

I have set org-fontify-done-headline to nil (Original value was t), to no avail.
Desired result:
Link is displayed as it is in TODO_NEXT state.


texts: how to include closing note in column view?

texts:
I'm trying to configure org-mode column view to display closing note of TODO entries so that I can see why they are closed easily. I read the manual but did not find a way.

Does anybody know a way to do this?


texts:
Here's an example:

   #+NAME: sys5
   #+HEADER: :exports both
   #+BEGIN_SRC maxima :results raw
     programmode: false;
     solution: triangularize(coefmatrix(
     [ -3*x - 11*y + 7*z = 0,
        2*x +  6*y - 2*z = 0,
          x +  2*y +   z = 0],
          [x, y, z]));
     print(solution);
   #+END_SRC

   # (1)
   #+RESULTS: sys5
   : [ - 3  - 11   7  ]
   : [                ]
   : [  0    4    - 8 ]
   : [                ]
   : [  0    0     0  ]
   # (2)
   #+BEGIN_EXAMPLE
     [ - 3  - 11   7  ]
     [                ]
     [  0    4    - 8 ]
     [                ]
     [  0    0     0  ]
   #+END_EXAMPLE

   Triangulated matrix of the above solution doesn't have pivot in the third
   column, thus it doesn't have a unique solution.

(1) is printed like so: [-3 -11 7] [] [0 4 -8] [] [0 0 0], but (2) prints properly, i.e. every line on the separate line. Interestingly, if there's some text after the #+RESULTS:, then export doesn't add = around the result, otherwise, it does.

Is there anything special about [] in results?


texts:
I have an executable (guix) in directory under home. I am using eshell. I add that directory to PATH. But when I run the command, the executable is not found. I have tried various methods such as addpath etc. But eshell doesnt seem to search in that directory and find the executable. If I give the full directory on the command line, it works.

See below:

$ /home/rlemmon/.guix-profile/bin/guix  works correctly
$ guix does not work

$ echo $PATH
$ /home/rlemmon/.guix-profile/bin:/home/rlemmon/bin:/ ...
$ addpath
/home/rlemmon/.guix-profile/bin/
/home/rlemmon/bin/
...


texts: Interpreter discrepancy in org-babel-python and python-mode

texts:
(Emacs version 26.1, Org version 9.1.9)

I have tried numerous solutions to get working in org-mode source blocks. This solution works to change python-mode to utilize the Python3 interpreter, which I have installed in the local directory. I believe the only relevant part of my config.org file is as follows:

  (setq exec-path (append exec-path '("c:/users/chenry/appdata/local/continuum/anaconda3")))
  (setq python-shell-interpreter "c:/users/chenry/appdata/local/continuum/anaconda3/python.exe")

; more settings...

(with-eval-after-load 'org
    (org-babel-do-load-languages
     'org-babel-load-languages
     '(; other babel languages
       (emacs-lisp . t)
       (org . t)
       (shell . t)
       (sql . t)
       (C . t)
       (plantuml . t)
       (R . t)
       (python . t))))

This works in python-mode, but not in org-mode python source blocks. I've also tried this solution, but I receive the Org-Babel Error Output:

  'python3' is not recognized as an internal or external command,
  operable program or batch file.

For example:

Any advice for how I can make python-mode and org-mode Python interpreters consistent? Thanks!


texts:
I am learning Emacs lisp and wrote a function which takes as input a list of file name, and
returns a list of numbers of each defun in a file (introduced in this tutorial)
(lengths-list-file "/usr/share/emacs/28.0.50/lisp/simpl.el")
=> (49, 49, 49, ... )

I tried to write another function, which takes a list of filenames and return an append-ed
list of return values of lengths-list-file of each element in the list.
(defun lengths-list-files2 (list-of-files)
  "Return list of lengths of defuns in LIST-OF-FILES."

  (let (lengths-list)
    (dolist (filename list-of-files lengths-list)
      (let (cur-lengths-list
            (lengths-list-file filename))
        (message "%d" (length cur-lengths-list))
        (setq lengths-list
              (append lengths-list
                      cur-lengths-list))))
    lengths-list))

Here I first used let to bind (lengths-list-file filename) to a symbol cur-length-list, however, I found out that cur-lengths-list was always nil.
Instead, I removed let expression, and I found that it started to work as I expected:
(defun lengths-list-files (list-of-files)
  "Return list of lengths of defuns in LIST-OF-FILES."

  (let (lengths-list)
    (dolist (filename list-of-files lengths-list)
      (setq lengths-list
            (append lengths-list
                    (lengths-list-file filename))))
    lengths-list))

What is the reason that the function with let within the dolist block failed to produce correct result? (i.e., why cur-lengths-list is always nil?)


texts: Figuring out what plugin is messing with my input

texts:
This is a more general question so I would like to know how to actually debug something like this. Suppose that I have some plugin that does section completion as code is being written. For example this can be bracket completion - I type { and } appears as well.

How can I actually find out which lisp function is making these modifications to the buffer? Is there some way to list all hooks being called during text entry?


texts: How to display window number in my mode-line?

texts:
I use window-numbering package to switch between windows in emacs, however I am struggling to display window number in my mode-line, preferably in [#] format (i.e. [1], [2],   [3] ...).

What variable can I use to append window number to my mode-line-format list? Please see below an example of my configuration.

(setq-default mode-line-format (list
    " "
    '(:eval (if (vc-backend buffer-file-name)
                (list
                 (propertize octicon-octoface 'face 'octicons-modeline)
                 (propertize " "              'face 'mode-line))))
   mode-line-mule-info
   'mode-line-modified
   "-  "
   'mode-line-buffer-identification
   "  (%l, %c)  "
   'mode-line-modes
   " -- "
   `(vc-mode vc-mode)
))

PS I've also tried a much newer winum package, with the same results...


texts: I work a lot with unix config files (i.e the files in /etc in the various linux system) that have no extension. How can I set-up my .emacs file to load conf-unix-mode on those files?


texts: Is there an easy way to check (in elisp) if only one character has changed in a buffer before saving it?

texts:
I have a typing problem in Emacs under WSL.  Sometimes it misses my typing ^x as in ^xp and ^xo (prev and next window in my bindings) and I get a stray p or o character in the buffer I want to leave (and I often don't notice it).  But it I save all buffers (like I do when typing compile/make), those stray characters can get written out.  There is usually just one of them.
So, I want to hack my save-buffer to check if the modification is just one character before saving and ask for comfirmation if it is.  Something like:
(defun my-save-buffer ()
  (interactive)
  (when (or (not (only-one-char-changed))
          (y-or-n-p "changed only one character, really save?")
          ) ; or
     (save-buffer)
     ) ; when
   )

The question is how to ask "only-one-char-changed" relatively efficiently?  E.g. something I can ask the undo information about.


texts: How can I read a single character from the minibuffer?

texts:
When part of a defun,

(interactive "c(C)hoose (A)n (O)ption")

will prompt the user for a single character; RET is not required.  How can I replicate this reading behavior without the need for interactive?


texts:
To get to my day page (agenda), currently I have to type in the following keys

C-c a (binded to (org-agenda))
a     (Agenda for current week or day)
d     (to switch from week-view to day-view)
C-c C-x C-c (to switch to column-view)

It's too much! Can I achieve the same thing by pressing just one key say <f10>, and hopefully without unnecessary evaluations? It's not as easy as normal key bindings I suppose, since one has to deal with the org agenda dispatcher.

EDIT: Answer found

See NickD's answer. The key is (org-agenda-list nil nil 1 nil) and details can be found in the manual of the function (org-agenda-list) by C-h f org-agenda-list <RET>. This way is much faster than the second answer below.
If you accept macro as a solution (which is slower), turn it into an elisp function by using the package elmacro and assign a keybind.


texts: Kill buffer when closing a frame only if that's the only frame showing that buffer?

texts: How can I kill a buffer when closing a frame only if that's the only frame showing that buffer?  Is there a way to check if the buffer in the selected frame is not in any other frame?


texts: How to fix Warning: assignment to free (local) variable in lambda function

texts:
The byte compiler just gave me this message

1103:24:Warning: assignment to free variable `orig-win-config

on this bit of code:

 ;; create window config store and restore functions
 ;; credit to @lawlist on stackoverflow for this embedded setup
 (setq mysetup
       (lambda ()
         ;; store original window configuration
         (set (make-local-variable 'orig-win-config)
              (current-window-configuration))
         ;; bind q to the window restore function
         (local-set-key
          "q"
          (lambda ()
            (interactive)
            ;; q is shared by all Help-mode buffers
            ;; so guard those that did not set up orig-win-config
            (when (boundp 'orig-win-config)
              (set-window-configuration orig-win-config))
            (kill-buffer (current-buffer))))))

The code runs in a defmacro that displays a temporary buffer window in Help-mode. The code creates a local function variable mysetup that can be called in the Help mode hook, to remember the original window configuration so the original configuration can be restored when the temporary help buffer is dispatched with "q".

The byte compiler apparently thinks that the (make-local-variable 'orig-win-config) statement creates a free variable that should not be assigned to this way.

Is there a way to change my syntax to keep the byte compiler happy, and to create/assign to the variable in a more correct way?

This question seems similar, but is not quite the same because it works with a (defun argument in the argument list, not a new variable in a (defmacro. So I don't know what to make of the info in that question.


texts: Issues adding super keybindings to term-mode-map on Mac OSX

texts:
I'm trying to bind Command-{ and Command-} to multi-term-prev and multi-term-next. I only want them in term-mode, since if I use it in a file buffer it will switch to show a terminal (which is rather undesirable). As I understand it, Command on Mac is Super inside Emacs by default, so this should work:

(define-key term-mode-map (kbd "s-}") 'multi-term-next)
(define-key term-mode-map (kbd "s-{") 'multi-term-prev)

However, even in a terminal I've verified to be in term-mode, Emacs complains that s-{ and s-} aren't defined (even when using [(super {)] instead of (kbd "s-{")). This works fine as a global keybind:

(global-set-key (kbd "s-}") 'multi-term-next)
(global-set-key (kbd "s-{") 'multi-term-prev)

This is the part of the variable term-mode-map that seems relevant, after the define-keys:

(keymap
  (8388731 . multi-term-prev)
  (8388733 . multi-term-next)
  ...
  (3 keymap
    (17 . term-pager-toggle)
    (10 . term-line-mode)
    (11 . term-char-mode)
    (4 . term-send-eof)
    (16 . term-previous-prompt)
    (14 . term-next-prompt)
    (12 . term-dynamic-list-input-ring)
    (5 . term-show-maximum-output)
    (18 . term-show-output)
    (15 . term-kill-output)
    (13 . term-copy-old-input)
    (28 . term-quit-subjob)
    (26 . term-stop-subjob)
    (3 . term-interrupt-subjob)
    (23 . backward-kill-word)
    (21 . term-kill-input)
    (1 . term-bol))
  (4 . term-delchar-or-maybe-eof)
  (13 . term-send-input)
  (27 keymap
    (12 . term-show-output)
    (4194419 . term-next-matching-input-from-input)
    (4194418 . term-previous-matching-input-from-input)
    (115 . term-next-matching-input)
    (114 . term-previous-matching-input)
    (110 . term-next-input)
    (112 . term-previous-input)))


texts: Is it possible to have shared #+PROPERTY: between multiple org files?

texts:
I'm working with org-mode and org-babel to query a PostgreSQL database. It's pretty cool setup and I love it.

At the moment, I have multiple org files with the same database property configuration like the following.

#+PROPERTY: header-args:sql :dbhost myhost
#+PROPERTY: header-args:sql+ :dbuser username :database secretdb :engine postgresql :exports result

This is duplicated in each org file now. I'm wondering if there's a way to configure this in one place and org-babel pick it up from.

I also have database configuration for multiple environments. So configuration for each database is also duplicated in the respective org files. It was fine in the beginning, now I have too many files with same +#PROPERTY: value in them, and it kind of getting confusing and tedious.

I'm looking for a way to have the configuration in one place and org-babel have them pickup.

Here's is what I tried so far.

#+INCLUDE: "./connection-properties.org"

You get the idea. This includes the org file, and also says Local setup has been refreshed when I do Ctrl-C-Ctrl-C. But when I execute the sql block, it fails with org-babel-execute:sql: Wrong type argument: stringp, nil

Looking for clues! Thanks!


texts: Fast data entry form something like org-agenda or magit

texts:
I would like to use emacs to enter data -- to start with, essentially a set of numeric responses to a list of questions.  The questions will usually be the same every day, but will change slowly over time.

I want the data to be recorded as plain text, but to use a more constrained interface than just typing plain text, so that it's faster to enter the data and less error-prone.  For example:

I would like j and k to move up and down between fields
I don't want to have to enter say evil's insert state in order to enter numeric values
I want the names of the questions to be automatically filled in and non-editable

The only code I've seen like this in emacs is org-agenda -- org-habit in particular is quite similar to what I have in mind.  However, org is a rather big code base, and though great software, not always the most exemplary elisp code in my book.  magit has a somewhat similar approach to interaction, though it happens not to have any UI you'd be likely to describe as "data entry".

Does anything like this already exist?  How can I go about implementing something like this?


texts: Dried+, Dired-K. Available space in KB/MB?

texts:
Windows 10, Emacs 25.1, Dired+, Dired-K

Here my dired buffer:

As you can see Dired-K show size of files and folder in KB/MB. OK. Nice.

But total available is show in bytes. Is it possible to show availabe space also in KB/MB?


texts:
I am trying to create a SVG image from latex code in an org-mode file.

#+name: foo
#+header: :file foo.svg
#+begin_src latex
bar
#+end_src

But I keep getting the following error:

executing Latex code block (foo)...
org-babel-execute:latex: HTML file produced but SVG file requested

On the Shell Command Output buffer the following error seems relevant, but I am not able to determine what is causing it.

[...]
(/usr/share/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/share/texmf-dist/tex/generic/tex4ht/html4-math.4ht)) (./latex-Mz7Vfn.aux)
Preview: Fontsize 10pt
Preview: Tightpage 0 0 0 0
[1]
! Output loop---100 consecutive dead cycles.
\newpage ...prevdepth \fi \fi \vfil \penalty -\@M

l.7 ...e{amsmath}\begin{document}bar\end{document}

?
! Emergency stop.
\newpage ...prevdepth \fi \fi \vfil \penalty -\@M

l.7 ...e{amsmath}\begin{document}bar\end{document}

Output written on latex-Mz7Vfn.dvi (1 page, 2384 bytes).
Transcript written on latex-Mz7Vfn.log.
[...]

Any idea on what am I doing wrong here?


texts: Elpy: how to stop the underlying RPC process?

texts:
Whenever elpy-mode is activated upon visiting a python file, I see a py.exe executable start, with a subtree of processes. This should be the remote procedure call (thanks @al0 for the explanation). It's what Elpy uses to check syntax, documentation, etc. Just to be clear I'm not speaking of the Python interpreter, started with run-python.

After I kill the buffer with the python code and elpy-mode, I see that the spanned RPC process and its tree are still alive. This happens even if I don't have any buffers, open or buried, with elpy-mode.

I don't quite see the point of the RPC remaining alive. Is this by design? Is there a command or function to kill it? At the moment I must open the task manager to kill it.


texts:
I want to unset the backspace key and I tried this:

(global-unset-key (kbd "<backspace>"))

Evaluating this in the buffer gives me nil but still the backspace key works as expected. How to unbind this?

After unbinding when I do C-h k on backspace it still shows me this:

  DEL (translated from <backspace>) runs the command autopair-backspace,
  which is an interactive compiled Lisp function in `autopair.el'.

  It is bound to DEL.

  (autopair-backspace)

  Possibly delete a pair of paired delimiters.


texts: Recover selected/highlighted key, val or cons before RET in completing-read

texts:
I have completing-read set to show me a plist.
I want to do something without RETURNING (completing the function).
E.g..:
(defun fancy-mode-call-buffer ()
  "List buffers to switch."
  (interactive)
  (let* ((visible-buffers-plist (working-function-returning-desired-plist))
     (key (completing-read "Buffer: "
                   visible-buffers-plist nil nil "^"))
     (val (alist-get key visible-buffers-plist nil nil #'string=)))
    (message "Called buffer: %s" val)
    (switch-to-buffer val)))

This function will list the visible-buffers using completing-read, and if I press RET it will "log" the called buffer with message and then switch-to-buffer to the desired buffer.
It's working.
What I need now, is to do actions before switching buffer (completing the function), like if I want to press C-x k to kill the highlighted/selected buffer just like in ivy-switch-buffer. How can I recover the "highlighted" cons?
Of course I need to create a key-map and define a custom C-x k to do the job, I think it's easy once I have the "current selected" item. But I don't know if this is possible in vanilla completing-read. I've been reading the documentation and searching without success, maybe I missed it?


texts: How to make the init file compatible with X and console at the same time?

texts:
I have customized the .emacs file a little to suit my taste, and it works fine when run in its own window.

But when I try to run it in my terminal using the command emacs -nw, it throws up the following error in a split view, with the other view running emacs properly on the console, albeit without a few of my customizations.

Warning (initialization): An error occurred while loading `/home/safiyat/.emacs':

error: X windows are not in use or not initialized

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

How is it possible to have an error free load of the init file on both X and the console?

Thank you.


texts:
In emacs on Windows 8.1 I can't open a file if its full name contains Russian letters [and generally any non-ascii char]. For example, if I try to open D:\ББББ\test.txt I get:

I find a config which seems relevant:

(setq default-file-name-coding-system 'cp1251)

and also tried to set it to utf-8 -- but it doesn't help. I use same config as on linux where I never had problems like this.

Edit:

I'm using vanilla emacs 24.3 for windows and the issue is reproduced with emacs -Q.

Edit 2:

I'm using English version of Windows:

PS D:\> reg query "hklm\system\controlset001\control\nls\language" /v Installlanguage

HKEY_LOCAL_MACHINE\system\controlset001\control\nls\language
    Installlanguage    REG_SZ    0409

(code 0409 means it is English). However other programs, e.g. notepad++, can open the file.

Edit 3:

Default code page is 437:

C:\chcp
Active code page: 437

and it doesn't have Russian chars.

Edit 4

Found an old thread -- seems like the problem is still there.

Edit 5:

Currently one can't open file with unicode in its full name using emacsclient. I'm using the following workaround in order to open files with unicode in their names in an opened emacs: one can use a custom multi-commander command:

I bind this to C-S-F4, and open dired in the respective folder, and browse to the file I want with dired. E.g. for d:\ББББ\test.txt I would open d:\ with C-S-F4 first, and browse to the test.txt with dired.


texts: emacsclient - discard unsaved changes on exit

texts:
I run emacs --daemon and emacsclient. When I C-x C-c from emacsclient, it will show the prompt

Save file /dir/filename.txt? (y, n, !, ., q, C-r, d or C-h)

for each file that has changes that haven't been saved.

If I enter n, emacsclient will exit, but then the next time I open emacsclient, it will ask me again if I want to save changes. Typically when I enter n I want to disacard the changes so that next time I run emacsclient, that file will be reverted to its state on disk.

How can I discard all unsaved changes when exiting emacsclient?

Current behavior:

emacsclient -a "" -t filename.txt
Make changes
C-x C-c
Save file /dir/filename.txt? (y, n, !, ., q, C-r, d or C-h)
n
emacsclient -a "" -t filename.txt
C-x C-c
Save file /dir/filename.txt? (y, n, !, ., q, C-r, d or C-h)
n

Desired behavior:

emacsclient -a "" -t filename.txt
Make changes
C-x C-c
Save file /dir/filename.txt? (y, n, !, ., q, C-r, d or C-h)
n (changes are discarded)
emacsclient -a "" -t filename.txt
C-x C-c (emacsclient exits)


texts:
I would like to write a custom elisp function that searches for a few variants of unicode text under a cursor and highlights their occurrences in the currently open file.
For e.g. if my text is helloम् (it ends with bytes U2350+U2381) the function should search a modified version of the text helloं (i.e. hello+U2306) The unicode bytes are always at the end of the word.
I started with a simple elisp function that would print a message if a text that matches my criteria is found and saving the modified string to be searched into a variable:
(defun c-search ()
  "If word under cursor ends with U2350+U2381, search for word+U2306"
  (interactive)
  (if (string-match-p "म्" (thing-at-point 'word))
  (setq z (replace-regexp-in-string "म्$" "ं" (thing-at-point 'word)))
  (message "Should search  %s" z)))

Nothing gets printed when I evaluate this function. However, the following function that searches and replaces the string works fine:
(defun rrx ()
      (interactive)
      (setq z (replace-regexp-in-string "म्$" "ं" (thing-at-point 'word)))
      (message z))

How can I fix function c-search to perform a search for the string saved in variable z?


texts:
I am unable to change keybinding in a minor mode.

Initiaton of minor mode:

(add-hook 'julia-mode-hook 'julia-repl-mode)

I tried a view variatons for the keybinding:

(add-hook 'julia-repl-mode
    (lambda ()
    (define-key map [C-shift-return] 'julia-repl-send-line)
    (define-key map [C-return] 'julia-repl-send-region-or-line)))

or:

(eval-after-load 'julia-repl '(define-key julia-repl-map [C-return]
                 'julia-repl-send-region-or-line))

But finally without result. I want to bind the command julia-repl-send-region-or-line to C-<eturn>.
I was at least able to change it interactively with M-x local-set-key. But I would like to define it in the init file.
What am I missing?


texts: attach multiple files from the same directory to an email message?

texts:
Q: how can I attach multiple files to an outbound email with a minimum amount of fuss?

I'm using mu4e (which reuses message-mode, if that helps) to work with email.  I often need to send emails with multiple attachments.  mu4e uses mml-attach-file to handle attachments.

So far so good.  However: it's an unpleasant task to use multiple attachments.  mml-attach-file prompts for each file anew, which is time-consuming when the file is buried deep in a subtree.

It is almost always the case that, when I need to attach multiple files, they are all in the same directory.  In this situation, how can I convince mml-attach-file to detect an attachment in the existing message buffer and, if it finds one, use that attachment's directory as the default for the next file I attempt to attach?

NB: If one digs into the source code, mml-attach-file relies on mml-minibuffer-read-file, which in turn uses either mml-default-directory or default-directory.

PS: I'm aware of How to attach multiple files in message-mode, but there's no answer there.


texts:
I want to define a trash directory in my user-init-file but I don't know which way to do this is best or most correct. I currently have something like this:

(defvar my-trash-dir
  (expand-file-name ".trash" user-emacs-directory))
(if (not (file-exists-p my-trash-dir))
    (make-directory my-trash-dir))
(setq trash-directory my-trash-dir)

Is this correct? Is there a better way to do this, maybe by using setq or defconst?


texts: load environment variables of virtual environment in emacs

texts:
What is the best way to load in emacs the environment variables of a virtualenv?

I seem to have got virtualenvwrapper.el working.  For example, after using venv-workon my_venv, then M-! printenv shows that the environment variable VIRTUAL_ENV has been set to my_venv.  Likewise, different virtualenvs load different python versions.

It also seems that I've got the package exec-path-from-shell.el working.  For example, in the terminal outside of any virtualenv the command  printenv shows MY_ENV_VARIABLE=oy. Now after doing (exec-path-from-shell "MY_ENV_VARIABLE") inside emacs, M-! printenv confirms that MY_ENV_VARIABLE=oy inside emacs as well.

So, I tried doing venv-workon my_venv and then  exec-path-from-shell MY_VENV_VARIABLE, which has been set in my_venv.  Then, exec-path-from-shell seems to find the value of MY_VENV_VARIABLE to be nil while actually it is voy.


texts: Automatically run ispell on magit COMMIT_MSG buffer

texts:
I make lots of spelling errors when constructing my commit message.
It would be cool if I could add a hook to magit such that when I execute
C-c C-c, it would run ispell before completing the commit message.

I can't figure out how to hack it, but I'm wondering if anyone else has tried to do this


texts: Indicate whether file has uncommited changes in mode line

texts:
In my mode line I can see if a buffer has unsaved changes (**- or a red x in my case, since I am using smart-mode-line).

Is there a similar way to display whether or not the file visited by the current buffer has uncommitted changes in  Git or whatever VCS you are using?